我有一个名为 vwMemberPolicyInfo
的 View ,我需要显示当年输入的所有记录。
我的查询是:
select
EffectiveDate AS [Month],
count(MemberID) AS Agents,
sum(ActualPremium) AS Premium
from
vwMemberPolicyInfo
Where
EffectiveDate > DATEADD(year, -1, GETDATE())
GROUP BY
EffectiveDate
但它不能正常显示结果:
2010-11-01 00:00:00.000 74 40644.00
2010-07-01 00:00:00.000 86 50418.00
2011-03-08 00:00:00.000 1 744.00
2011-04-08 00:00:00.000 1 0.00
2010-11-02 00:00:00.000 5 2676.00
2011-04-14 00:00:00.000 1 1185.00
2011-02-28 00:00:00.000 7 2988.00
2011-02-23 00:00:00.000 8 8518.00
2011-04-10 00:00:00.000 1 1332.00
2011-04-07 00:00:00.000 3 2544.00
我只需要显示当年的条目..提前致谢
最佳答案
尝试 where YEAR(EffectiveDate) = YEAR(GETDATE())
希望对您有所帮助。
关于sql-server - 从 SQL Server 中的 View 获取当年的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5676170/