.NET 學習

.NET 學習生活感想... 万事成蹉跎..... 贵在坚持 及时整理自己做过和学过的东西

博客园 首页 新随笔 联系 订阅 管理

 

代码
declare   @t   table   (Date   datetime,   Name   varchar(30),   Money   money)   
  
insert   @t   
  
select   dateadd(dd,10,getdate()),'a',10.0000   union   all   
  
select   dateadd(dd,11,getdate()),'a',10.0000   union   all   
  
select   dateadd(dd,12,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,13,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,6,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,-1,getdate()),'a',10.0000   union   all   
  
select   dateadd(dd,-2,getdate()),'a',10.0000   union   all   
  
select   dateadd(dd,-3,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,-4,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,-40,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,-20,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,30,getdate()),'b',10.0000   union   all   
  
select   dateadd(dd,60,getdate()),'b',10.0000   
  
SELECT   CONVERT(VARCHAR(7),Date,120)+'-'+   
  
case   when   day(date)   between   1   and   15   then   '上半月'   else   '下半月'   end,   
  Name,   
  
SUM(Money)     
  
FROM   @t   t   
  
GROUP   BY   CONVERT(VARCHAR(7),Date,120)+'-'+   
  
case   when   day(date)   between   1   and   15   then   '上半月'   else   '下半月'   end,   
  Name

 

 

posted on 2010-05-11 08:39  Tonyyang  阅读(419)  评论(0编辑  收藏  举报
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/