|
-
Oct 11th, 2000, 10:28 AM
#1
Thread Starter
Addicted Member
Hi
What SQL statement should i write if i want to select a data from a column that has duplicate data?
Any help or suggestion will be greatly appreciated
-
Oct 11th, 2000, 10:33 AM
#2
Lively Member
I assume you only want the single occurence of the duplicates? just use DISTINCT. ie if you've a 'firstname' column (where you'll probably get multiple 'Steve's and 'Sarah's) you'd do:
Code:
SELECT DISTINCT forename FROM names ORDER by forename
Anakim
It's a small world but I wouldn't like to paint it.
-
Oct 11th, 2000, 10:38 AM
#3
Thread Starter
Addicted Member
Thanks for the reply ANAKIM
But what should i do if that column contain duplicate numbers ?
-
Oct 11th, 2000, 10:45 AM
#4
Lively Member
Exactly the same! It matters not a jot what the column contains. Distinct can be used for multiple columns, say if you were looking for all the different results in an exam, if the table contained names and sexes of the entrants as well as the mark....
Code:
SELECT DISTINCT score FROM entrants
would get all the different scores while...
Code:
SELECT DISTINCT score, sex FROM entrants
would get all the different scores for male, female and in-betweens.
Anakim
It's a small world but I wouldn't like to paint it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|