[英]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.