SQLServer查询近三年的数据
declare @annual int =2020 select * from tbName where DATEDIFF(YEAR,CAST( annual as varchar),cast(@annual as varchar)) between (case when @annual=YEAR(GETDATE()) then 0 else -1 end) and (case when @annual=YEAR(GETDATE()) then 2 else 1 end)