我不擅长 sql,所以任何帮助世界都很棒
我有一个 SQL 查询,它获取从一月到本月注册的记录
我的代码示例
SELECT DatePart(YEAR, p.createStamp) as TheYear, DatePart(MONTH, p.createStamp) as TheMonth , COUNT(p.pId) AS TOTALCOUNT
FROM profile p with(nolock)
where DatePart(YEAR, p.createStamp) = DATEPART(YEAR, GETDATE())
GROUP BY YEAR(p.createStamp), MONTH(p.createStamp)
ORDER BY YEAR(p.createStamp), MONTH(p.createStamp)
查询将如何带回
二月 = 2,三月 = 3,四月 = 4,五月 = 5
我想让它带回 Jan = 1 总计数为 0 和 June = 6 总计数为 0 以及任何想法如何做到这一点?
谢谢你。