Hi @Ryan Abbey ,
Please refer below and check whether it is helpful to you.
SELECT
REPLACE(
REPLACE( (SELECT
c.ClassName,
s.StudentName
from #tabClass as c
RIGHT OUTER JOIN #tabStudent as s ON s.ClassGuid = c.ClassGuid
order by
c.ClassName,
s.StudentName
FOR
JSON AUTO),'{"StudentName":','' ),
'"}','"' )
Output:
[{"s":["Carla Cap"]},
{"ClassName":"Algebra Math","s":["Alice Apple"]},
{"ClassName":"Art Painting","s":["Betty Boot"]},
{"ClassName":"Calculus Math","s":["Alice Apple","Betty Boot"]}]
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.