p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

sql_language thread: Finding multiple occurrences of a value in a column

Message #1 by "Christian Cryder" <christianc@g...> on Thu, 14 Mar 2002 10:21:39 -0700
Use the DISTINCT predicate.  As in,

select DISTINCT SomeVal, [ID] from YourTable

Use DISTINCT on only one column and the first column in your select

-----Original Message-----
From: Christian Cryder [mailto:christianc@g...]
Sent: Thursday, March 14, 2002 11:22 AM
To: sql language
Subject: [sql_language] Finding multiple occurrences of a value in a

Sorry if this is a stupid question, but I'm stuck. Let's say that I have
simple table like this:

ID		SomeVal
--------	---------
1		1234
2		23
3		1234
4		45
5		56

How would I write a query that says "Show me any rows where SomeVal
more than once in the table"? In other words, I'd like to get back:
1		1234
3		1234

I'm basically trying to query to make sure that all the SomeVal values
unique. Suggestions?

Christian Cryder [christianc@a...]
Internet Architect, ATMReports.com
Barracuda - http://barracuda.enhydra.org
 "What a great time to be a(n employed) Geek"

  Return to Index