标签:
--上周数据 datepart(week,AddDate)跨年会有问题
SELECT * FROM UsersWHERE datepart(week,AddDate)=datepart(week,getdate())-1
--上月数据
SELECT * FROM Users WHERE datediff(month,AddDate,getdate())=1
--将为null值转换成0
SELECT convert(int,isnull(u.EmpiricalValue,0)) FROM Users
标签:
原文地址:http://www.cnblogs.com/autocephaly/p/5101714.html