Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How do I find out those duplicates using SQL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Wed Sep 17, 2008 8:21 am    Post subject: How do I find out those duplicates using SQL
Reply with quote

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
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Sep 17, 2008 8:55 am    Post subject:
Reply with quote

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
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Wed Sep 17, 2008 9:33 am    Post subject: Reply to: How do can this be done ?
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Sep 17, 2008 11:26 am    Post subject:
Reply with quote

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
View user's profile Send private message
Cristopher

New User


Joined: 31 Jul 2008
Posts: 53
Location: NY

PostPosted: Wed Sep 17, 2008 2:12 pm    Post subject: Reply to: How do I find out those duplicates using SQL
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm
No new posts Command to find TMEMBER name for a TPIPE Siva NKK Kothamasu IMS DB/DC 0 Wed Aug 16, 2017 6:08 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us