Click here to Skip to main content
12,300,021 members (49,686 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# SQL-Server
hello friends,


i have one table and there is record like that


ID Amount
1 100
2 500
3 1500
4 5800

now i want to get record like
1 100 100
2 500 600
3 1500 2100
4 5800 7900


can any one help me for this query to get record like this...!!

Thank You all...!!
Posted 2-Oct-12 23:28pm
Comments
Zoltán Zörgő 3-Oct-12 5:30am
   
You want a running summary?
Yatin chauhan 3-Oct-12 6:21am
   
Yes Zoltan....!!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Yatin chauhan 3-Oct-12 6:04am
   
Thank a Lot Dylan Morley....!!!!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

insert into @t
select 1,10
union
select 2,12
union
select 3,3
union
select 4,15
union
select 5,23
 

select * from @t
 
select t1.id, t1.SomeNumt, SUM(t2.SomeNumt) as sum
from @t t1
inner join @t t2 on t1.id >= t2.id
group by t1.id, t1.SomeNumt
order by t1.id


Thanks
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

If you need running totals in just T-SQL, start from here: http://www.sqlhacks.com/Summary/Running_Total[^].
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160525.2 | Last Updated 3 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100