I believe that you are looking for something like this -
Attach a collection of objects to a comma separated string
I would be inclined to pull the data the same way you did GROUP BY in you in a question, and then combine the values ββof the numbers for each object in your asp.net code.
Or you could write a VBA function to use in Access for this. Allen Browne is already written here . You just need to add the code to the module inside Access, and then you can use this function in SQL queries in Access.
Given this table structure
subjects table id | SubjectName | Grade --------------------------------- 1 MATH 5 2 ENGLISH 3 3 ENGLISH 2 4 PHYSICS 5 5 MATH 1 6 MATH 3
Next SQL with VBA Function
SELECT subjects.SubjectName + ' ' + ConcatRelated("Grade","subjects","SubjectName='" & SubjectName & "'") AS result FROM subjects GROUP BY subjects.SubjectName
gives the following result:
result ------------ ENGLISH 3, 2 MATH 5, 1, 3 PHYSICS 5
if you want to receive the order that you indicated in your question, you will need another field / expression on which ordering will be performed
source share