View previous topic :: View next topic
|
Author |
Message |
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Hi,
I have this requirement:
The DB2 tables looks like this
Feild A
Feild B
Feild C
In these feilds we have some duplicates.
How do I find out those duplicates. ?
Can this be done with an SQL ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you post some sample rows and show the output you want when those rows are processed, someone will be able to make suggestions.
As posted, your question is not clear. |
|
Back to top |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Hello,
This is how my DB2 table looks like
Feild A Feild B Feild C
Tom Toronto Postalcode1
Tom Toronto Postalcode1
Tom Toronto Postalcode1
Harry Montreal Postalcode2
Harry Montreal Postalcode2
My output should be
Tom Toronto Postalcode1
Tom Toronto Postalcode1
Tom Toronto Postalcode1
Harry Montreal Postalcode2
Harry Montreal Postalcode2
Please note that I cant hardcode these values in where clause. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Your sample data does not deal with selecting duplicates. . . A simple SELECT * with no WHERE would get that result.
Suggest you post more representative data including some rows that would not be selected as well as some that would. |
|
Back to top |
|
|
Cristopher
New User
Joined: 31 Jul 2008 Posts: 53 Location: NY
|
|
|
|
ap,
as Dick has indicated your requirement is not clear enough to suggest a solution.
If you wish to identify only the duplicates in the table on all the 3 fields thn this query might help
Code: |
SELECT A,B,C FROM SAMPLE_TABLE
GROUP BY A,B,C
HAVING COUNT(*) > 1; |
|
|
Back to top |
|
|
|