October 15, 2007 at 10:47 pm
I need the below query to return the actual_amt grouped by all the business units..I dont need the output at individual business units. (i.e the actual amount should be the consolidated amount of all the business units 100,200, 300, 400. Please advice.
select a.company, d.company_desc, b.acct1, b.acct2, sum(c.actual_amt)
from
fact a,
join hierarchy b on (A.ID = b.id)
join date c on (a.date_id = c.date_id)
join bus d on (a.bus_id = d.bus_Id)
where bus_unit in (100,200,300,400)
and year(c.date_id)= '2007'
group by a.company, d.company_desc, b.acct1, b.acct2
having sum(c.actual_amt) <> 0
October 16, 2007 at 12:12 am
Could you possibly post the schema of those tables, some sample data and your desired output please? Without those we're kinda working blind.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply