3

我很难组装一条 SQL 语句。场景/要求是这样的:我需要对当前季度的一个字段进行计数。

SELECT COUNT(fieldname) AS Hits 
FROM tablename 
WHERE DatePosted = (Current Quarter)

我想获得当前季度的点击次数/计数。

这可能吗?

4

1 回答 1

6
select count(fieldname) as Hits 
from tablename
where datepart(q,DatePosted) = datepart(q,getdate())
and year(DatePosted) = year(getdate())
于 2013-07-11T06:49:36.850 回答