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

Tossing out duplicates 1

Status
Not open for further replies.

Sashanan

Programmer
Jan 19, 2001
235
NL
I am trying to select all unique values in a column, while tossing out any duplicates so every value shows up only once. I know there was an easy way to do this; now if only I could remember what it was.

SELECT Column1
FROM Table1
ORDER BY Column1

Can anyone refresh my memory and tell me what I need to add to this to toss out the duplicates?
"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
Hiya,

If you just want to see unique values, what you need is :

SELECT DISTINCT Column1
FROM Table1
ORDER BY Column1

If you want to see duplicate values, you need

SELECT Column1
COUNT(*)
FROM Table1
GROUP BY Column1
HAVING COUNT(*) > 1

Tim
 
Hiya,

If you just want to see unique values, what you need is :

SELECT DISTINCT Column1
FROM Table1
ORDER BY Column1

If you want to see duplicate values, you need

SELECT Column1
COUNT(*),
FROM Table1
GROUP BY Column1
HAVING COUNT(*) > 1

Tim
 
DISTINCT! That was it. Thank you for reminding me. :)

21 years and already forgetful. I sure hope I never get to program something important.
"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top