我想根據基於datetime
的where子句對數據集進行分組,但我需要爲Account
表中不符合where date
要求的任何用戶返回計數0。這是我的SQL語句:Group By with Where
select a.userid, count(c.codeentryid)
from [account] a
left join codesentered c
on a.userid = c.userid
where a.camp = 0 and c.entrydate > '2013-12-03 00:00:00'
group by a.userid
order by a.userid
目前我得到的所有計數誰滿足entrydate
需求的用戶,但我怎麼也將返回誰不符合爲0的計數這一要求的用戶?