SqlServer获取一周内每天的金额统计数据

Posted on 2020-05-11 11:14  快醒醒  阅读(1595)  评论(0编辑  收藏  举报
select  datename(weekday,CAST([CompletedTime] AS date)) WeekNum,  
CAST([CompletedTime] AS date) AS 'Date' , 
SUM(case when OrderStatus=2 and IsDeleted=0 then  PlatformAmount else 0 end) as PlatformAmount,
SUM(case when OrderStatus=2 and IsDeleted=0 then  AgentAmount else 0 end)  as AgentAmount,
SUM(case when OrderStatus=2 and IsDeleted=0 then  TenantAmount else 0 end) as TenantAmount
from QYNET_Order where datediff(week,CompletedTime,getdate()-1)=0 
group by CAST([CompletedTime] AS date) 
order by Date
————————————————
版权声明:本文为CSDN博主「xiaobingge2018」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiaobingge2018/java/article/details/103830406

  

 

 

该博客仅做记录使用。侵删。

 

Copyright © 2024 快醒醒
Powered by .NET 9.0 on Kubernetes