"Snyd"-løsning ved hjælp af GROUP_CONCAT()
. Dette vil ikke vise antallet af spørgsmål, der ikke er relateret til noget emne:
SELECT
TopicIds
, COUNT(*) AS QuestionCount
FROM
( SELECT
QuestionId
, GROUP_CONCAT(TopicId ORDER BY TopicId) AS Topics
FROM
QuestionTopic
GROUP BY
QuestionId
) AS grp
GROUP BY
Topics