[英]Group by week day and Month
如何按月和周计分数据
我知道这是错的..
select sum(x) from demo_table
group by DATEPART(month,date)
where DATENAME(weekday,date)='sunday' ;
where子句不能在组内使用...但这是我想要的
将where
子句放在group by
之前:
select sum(x)
from demo_table
where DATENAME(weekday,date)='sunday'
group by DATEPART(month,date) ;
你可能想要
select sum(x)
from demo_table
where DATENAME(weekday,date)='sunday'
group by DATEPART(month,date)
[WITH common_table_expression]
SELECT select_list [INTO new_table]
[FROM table_source] [WHERE search_condition]
[GROUP BY group_by_expression]
[HAVING search_condition]
[ORDER BY order_expression [ASC | DESC]]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.