日期:2014-05-18 浏览次数:20665 次
create table #t (proName varchar(50), date int, [money] float, yumoney float, syumoney float, allmoney float) insert #t select 'mmmmmmm', 8, 1000, 1500, 500, 2000 union all select 'mmmmmmm', 9, 1000, 500, 1500, 0 select proName, date, (select sum([money]) from #t where date <= t.date and proName = t.proName) [money], yumoney, syumoney, (select sum([allmoney]) from #t where date <= t.date and proName = t.proName) allMoney from #t t where date = 9