很长一段时间我都在努力学习以下主题:我想计算datepart值。我使用SQL Compact Edition 4.0并且不知道如何获得以下内容:
select datepart(week, CreateDate) as Week, count(*) from tblOrders
where CreateDate>'12 April 2010' and CreateDate<'25 June 2011'
这显然不起作用,但是为了让您了解我想要得到的结果是: - 2列,
提前致谢,
皮特
答案 0 :(得分:1)
您需要添加分组依据才能使查询语法正确。
select datepart(week, CreateDate) as Week, count(*)
from tblOrders where CreateDate>'12 April 2010' and CreateDate<'25 June 2011'
group by datepart(week, CreateDate)
这有帮助吗?