Let's go

sql备份

SELECT id,Name FROM TeachSite GROUP BY id




select top 1000  1 as [type],SchoolRollID,ChargeableAmount  into #temp from ChargeRecord where bflag=1


select * from #temp  



select 2 as [type], SchoolRollID,SUM(ChargeableAmount) as xj
into #tempxj
 from #temp   group by SchoolRollID

 select 0 as  [typq], null as  SchoolRollID ,SUM(xj) as hj  into #temphj from #tempxj 


 select *  from #temp


insert  into #temp
 select * from #tempxj


insert  into #temp
 select * from #temphj


 select * from #temp order by SchoolRollID,[type] desc 

 

posted @ 2019-02-22 18:43  chenze  阅读(124)  评论(0)    收藏  举报
有事您Q我