摘要:
准备案例数据:--SQLcode--建表createtable#Temp(datedatetime,Dcountint)insertinto#Tempselect'2010-01-01',10unionallselect'2010-01-25',10unionallselect'2010-01-31',15unionallselect'2010-02-25',30unionallselect'2010-02-28',20unionallselect'2011-01-03',20unionallsel 阅读全文
摘要:
--1。得到当前月的天数select datepart(dd,dateadd(dd,-1, --2011-04-30 00:00:00.000dateadd(mm,1,cast(cast(year(getdate()) as varchar)+'-' --2011-04-01 00:00:00.000 +cast(month(getdate()) as varchar)+'-01' as datetime) --2011-05-01 00:00:00.000)))--2.应用case划分 等级 select productid,productName,unitP 阅读全文