因此,我将汇总内容从编辑内容切换到我的原始帖子,现在可以正常工作了:
询问
SELECt CAST(a.IndexedDate as varchar) as dt, COUNT(EventType) AS LoginsFROM ( SELECt DISTINCT(IndexedDate) FROM Table WHERe IndexedDate > DATEADD(mm, -1, GETDATE()) ) aFULL OUTER JOIN ( SELECt * FROM Table WHERe IndexedDate > DATEADD(mm, -1, GETDATE()) AND EventType = 'Login' ) bON a.IndexedDate = b.IndexedDateGROUP BY a.IndexedDateORDER BY a.IndexedDate DESC
结果
2016-09-13 412016-09-12 312016-09-11 02016-09-10 02016-09-09 152016-09-08 36
请注意,我必须替换为
COUNT(*),
COUNT(EventType)这样它才不会从合计中计算得出1的日期。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)