gpt4 book ai didi

最近 6 个月的 SQL Server 查询

转载 作者:行者123 更新时间:2023-12-05 02:14:45 25 4
gpt4 key购买 nike

每次我更新数据时,我希望它只反射(reflect)最近 6 个月的数据。以下是我当前的查询。有人可以帮我解决这个问题吗?

SELECT ar.[Report Date]
,ar.Facility
,SUM (ar.[0-30]) AS [0-30]
,SUM (ar.[31-60]) AS [31-60]
,SUM (ar.[61-90]) AS [61-90]
,SUM (ar.[91-120]) AS [91-120]
,SUM (ar.[120+]) AS [120+]
FROM DBO.ARByPayer AS ar
WHERE ar.[Current Financial Class] <> 'Lien'
GROUP BY ar.Facility, ar.[Report Date]
ORDER BY ar. [Report Date]

最佳答案

如果我正确理解您的要求,您需要将此添加到您的 where 子句中:

and ar.[Report Date] > DATEADD(m, -6, GetDate())

关于最近 6 个月的 SQL Server 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53160964/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com