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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

group and ungroup sum

Status
Not open for further replies.

xponcall

IS-IT--Management
Aug 1, 2007
9
US
I have the following:

Select t0, t1,t2,t3,t4,sum(x1)as tx1,sum(x2)tx2
into tbl2 From Tbl1
Group by t0,t1,t2,t3,t4
Having (sum(x1)+sum(x2))> 10

trying to ungroup the above by flaging the tx column to 'Y':

update a set a.tx='Y'
from tbl1 a inner join tb2 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

select t0, t1,t2,t3,t4,x1,x2
into tbl3 from tbl1 where tx='Y'

trying to get these value to be the same:

select sum(tx1),sum(tx2) from tb2
select sum(x1), sumx(2) from tb3

However the sum for both table are different. Anyone have any suggestion?

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top