Need suggestions on a MS SQL query:
table: students
id name class
-- ---- -----
1 John Math, Biology
2 Jane English
3 Mark Math
table: class
id name
-- ----
1 Math
2 English
3 Biology
4 History
Desired output
name count
---- -----
Math 2
English 1
Biology 1
History 0
classand in it you need to parse the comma list to get the class names? I notice in your exampleSciencedoesn't appear anywhere except in theStudentstable. Is that a bug or do you really not what that result?