如何通過月份和星期組數據集團由週日期和月份
我知道這是不對的..
select sum(x) from demo_table
group by DATEPART(month,date)
where DATENAME(weekday,date)='sunday' ;
where子句不能內按... 但這種使用是想我需要
如何通過月份和星期組數據集團由週日期和月份
我知道這是不對的..
select sum(x) from demo_table
group by DATEPART(month,date)
where DATENAME(weekday,date)='sunday' ;
where子句不能內按... 但這種使用是想我需要
你可能想
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]]
把where
子句group by
前:
select sum(x)
from demo_table
where DATENAME(weekday,date)='sunday'
group by DATEPART(month,date) ;
你可以試試'having'而不是'where' – Miller