Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT: ROLL UP problem 1

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
US
Hi all,
I am struggling with the following table to get my things fixed..couldnt figure out how the rollup function is behaving..ANY HELP..

i have the follwing table
TimeInterval Group ActualTime
-------------------------------------
9.00 1 100
9.00 2 150
9.00 3 100
10.00 2 100
10.00 3 160

---------------------------------------
I want the follwing output
-----------------------------------
TimeInterval Group ActualTime EffectiveTime
-------------------------------------
9.00 1 100 350
9.00 2 150 350
9.00 3 100 350
10.00 2 100 260
10.00 3 160 260


The thing is that..the total of the actual time on all the groups rolls up to each group in that interval

i did like
select timterval,group,actualtime,grouping(group)
From <table>
group by timeinterval,group,actualtime,ROLLUP(group)
order by group

I am getting all Zeros and this is my first ROLLUP usage..

thanks in advance
logic4fun

 
As it seems as you are on 4.1.1 you can use a scalar subquery.

Code:
select TimeInterval,Group,ActualTime,
(select sum(ActualTime) from t
  where TimeInterval = q.TimeInterval)
from t as q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top