我如何使用where子句从startdate开始添加2小时/天的总和,以获取一周/ 7天sql服务器中不同日期的确切金额

问题描述

例如declare @startdatetime as datetime set @startdate = '2020-07-27 06:00:000'

输出 this is for 1 day

我的第一个查询

Select SUM(CAST(Amount as int)) as amount from TABLE where CAST(datecolumn as datetime) between @STARTDATETIME and Dateadd(HOUR,2,@STARTDATETIME

我需要包括第二天,最多7天或一周。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)