SUM(CASE
WHEN DATEDIFF(d , TransactionDate , '2018/05/09') BETWEEN 100 AND 600
THEN (TotalValue-TotalPaidtoDate)
end )AS [30DaysAmount]
答案 0 :(得分:0)
你的意思是今天的约会吗?如果是,请使用getdate()
:
SUM(CASE WHEN DATEDIFF(day, TransactionDate , GETDATE()) BETWEEN 100 AND 600
THEN (TotalValue - TotalPaidtoDate)
END) AS [30DaysAmount]
我不确定列名称与期间的501天有什么关系。