sql server 中按照周進行匯總
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
一種寫法:
select sum(number) as 銷售總額,DATEPART(week,sell_date),convert(varchar(10), dateadd(day,-1,DATEADD(wk,datediff(wk,0,rtrim(datepart(year, sell_date )))+datepart(wk,sell_date )-1,0)) , 20)
from sell_info where 1=1 and sell_date >= '2011-01-01' and sell_date <= '2011-03-01'
group by DATEPART(week,sell_date), convert(varchar(10), dateadd(day,-1,DATEADD(wk,datediff(wk,0,rtrim(datepart(year, sell_date )))+datepart(wk,sell_date )-1,0)) , 20) 其他寫法: 該文章在 2023/3/7 23:36:47 編輯過 |
關鍵字查詢
相關文章
正在查詢... |