Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 query question
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

26 Posts

Posted - 10/03/2006 :  11:15:39  Show Profile  Reply with Quote
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

Premature Yak Congratulator

22864 Posts

Posted - 10/03/2006 :  11:21:44  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Can you some sample data?


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

Flowing Fount of Yak Knowledge

5581 Posts

Posted - 10/03/2006 :  11:22:11  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
Like this??

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

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

In (Som, Ni, Yak)

17689 Posts

Posted - 10/03/2006 :  11:22:21  Show Profile  Reply with Quote

select	Cusip
from	table
group by Cusip
having sum(holding) <> 0


Go to Top of Page

In (Som, Ni, Yak)

17689 Posts

Posted - 10/03/2006 :  11:22:52  Show Profile  Reply with Quote
x 2


Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000