1、case。
select DeptName,
isnull(sum(1),0) as cAll,
isnull(sum(case when isnull(A01072,’已审核’) = ‘已审核’ then 1 end),0) as cYes,
isnull(sum(case when isnull(A01072,’未审核’) = ‘未审核’ then 1 end),0) as cNo
from view_UserStandInfo group by DeptName
2、top。
select top 10 * from Test
3、update set from。
update A set a1 = b1, a2 = b2 from A, B where A.ID = B.ID
4、取整/取余。
select floor(88/60), floor(88%60)
5、上月26号/本月25号。
–上月26号
select dateadd(day, 26, dateadd(month, -1, dateadd(day, 0-day(getdate()), getdate()) ) )
–本月25号
select dateadd(day, 25, dateadd(day, 0-day(getdate()), getdate()) )
6、日期格式。
select getdate()
2007-04-28 10:06:12.122
select convert(varchar, getdate(), 120 )
2007-04-28 10:06:12