Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL2000 - Aggreate column

Author  Topic 

Akshaya Pargunan
Starting Member

10 Posts

Posted - 2011-10-11 : 10:26:25
i have a table like below

DateofRequest hours
---------------- ------
10/10/2011 3
11/10/2011 6
12/10/2011 7
13/10/2011 2
14/10/2011 1
15/10/2011 9

I want one more column in this with below condtion

DateofRequest hours Total Hours
---------------- ------ -------------
10/10/2011 3 3
11/10/2011 6 3+6
12/10/2011 7 3+6+7
13/10/2011 2 3+6+7+2
14/10/2011 1 3+6+7+2+1
15/10/2011 9 3+6+7+2+1+7

Formula for
Totalhours = sum(hours) where DateofRequest < all DateofRequest date less then current row

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-10-11 : 10:27:56
this is running total


select DateofRequest, hours, [Total Hours] = (select sum(hours) from tbl x where x.DateofRequest <= t.DateofRequest)
from tbl t



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Akshaya Pargunan
Starting Member

10 Posts

Posted - 2011-10-12 : 04:17:54
Thank u very much
it helped me
Go to Top of Page

adityasingh.n.solanki
Starting Member

1 Post

Posted - 2011-10-12 : 04:43:57
I want the complete execution of the query of finding the 2nd most highest salary among the employees?
Help me please.

Aditya
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-10-12 : 07:12:30
quote:
Originally posted by adityasingh.n.solanki

I want the complete execution of the query of finding the 2nd most highest salary among the employees?
Help me please.

Aditya



sounds like homework to me


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -