If you donβt need each individual value in a comma-separated list, but say only until the first 3 or 4 or so, then Access has a pure SQL solution.
I am working on a database for a non-profit organization that has Tutors and Classes. For most classes there are only 1-2 teachers. To display goals, I cannot list more than 2 or 3 in any case, so I donβt worry about trimming emissions with the help of 5 or more teachers.
This will capture 3 teachers for each class with the lowest Tutor identifiers.
Select JTC1.ClassID, Min(JTC1.TID1) as TutorID1, Min(JTC1.TID2) as TutorID2, Min(JTC1.TID3) as TutorID3 from ( Select distinct TC1.ClassID, TC1.TutorID as TID1, TC2.TutorID as TID2, TC3.TutorID as TID3 from (( Classes C Left Join TutorClasses TC1 on C.ClassID = TC1.ClassID) Left Join TutorClasses TC2 on TC1.ClassID = TC2.ClassID and TC1.TutorID < TC2.TutorID ) Left Join TutorClasses TC3 on TC2.ClassID = TC3.ClassID and TC2.TutorID < TC3.TutorID ) as JTC1 Group by JTC1.ClassID
Obviously, it takes 1 extra step (not shown) to combine the three columns into 1.
Rickm source share