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
 General SQL Server Forums
 New to SQL Server Programming
 N00b to SQL and needs help :)

Author  Topic 

OSXFreak
Starting Member

1 Post

Posted - 2010-12-02 : 09:29:22
I am not sure where to begin, but I have the need to select unique records in a list.

Basically here's what I have.

Product# Whse#
abc 1
abc 2
abc 3
abc 4
def 2
a1a2 2
a1a2 1
a5a5 1
www 1
www 2
www 3

So based on the above, I need to select the part numbers in whse 1 and 2, that do not exsist in any other whse. So basically I would need to ONLY select def, a1a2(whse 2),a1a2(whse 1) and a5a5. Ignoring the items if they already exsist in whsr 3, 4 and so on.

Thanks for any assitance you can offer in this.

Chip

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-02 : 09:34:27
select product#, max(whse#)
from tbl
group by product#
having max(whse#) <= 2

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -