如果它为空,我怎样才能得到计数为 0。当我使用以下语句运行时:
SELECT S.shortText, COUNT(O.selectionID) AS C FROM Opinions O
LEFT JOIN Selections S ON S.id=O.selectionID
WHERE S.qID=3 AND MONTH(O.entryDate)=5
GROUP BY S.shortText
shortText C
---------------- ----
Leisure 0 <------ this line missing
Business 3
University visit 1
我的选择表
id shortText
----- ----------------
1 Leisure
2 Business
3 University visit
我的意见表
id entryDate selectionID
----- --------------------- --------------
186 5/21/2012 11:34:37 AM 2
205 5/22/2012 9:13:25 AM 2
216 5/22/2012 9:43:14 AM 2
237 5/24/2012 8:24:00 PM 3