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 2005 Forums
 Transact-SQL (2005)
 ungroup value

Author  Topic 

hai
Yak Posting Veteran

84 Posts

Posted - 2007-12-20 : 16:09:19
I have the following:
Select t0, t1,t2,t3,t4,sum(x1)as tx1,sum(x2)tx2
From Tbl1
Group by t0,t1,t2,t3,t4
Having (sum(x1)+sum(x2))> 10

trying to ungroup the above, which when add a.x1 all together
they should = tx1 above but it is not. Can someone point to me what I'm missing?

thanks

select a.t0,a.t1,a.t2,a.t3,a.t4,a.x1,a.x2
from Tbl1 a inner join (select
t0,t1,t2,t3,t4 from Tbl1)b
on a.t0=bt0 and
a.t1=b.t1 and
a.t2=b.t2 and
a.t3=b.t3 and
a.t4=b.t4
   

- Advertisement -