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)
 query question

Author  Topic 

cronid
Starting Member

26 Posts

Posted - 2006-10-03 : 11:15:39
I’ve got a table of cusips and account holdings where I only want to display the cusips whose holdings’ sum does not equal 0. It’s the fourth cusip in the example below. Do you have an idea about how to code the sql?

Cusip holding

00080S101000 -71
00080S101000 200
00080S101000 -100
00080S101000 -29
00104Q107000 9605
00104Q107000 -9605
001204106000 100
001204106000 131
001204106000 -231
00163T109000 -214
00163T109000 114

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-03 : 11:21:44
Can you some sample data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-03 : 11:22:11
Like this??

Select CUSIP
From Tbl
Group by CUSIP
having sum(holding) <> 0


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-03 : 11:22:21
[code]
select Cusip
from table
group by Cusip
having sum(holding) <> 0
[/code]


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-03 : 11:22:52
x 2


KH

Go to Top of Page
   

- Advertisement -