Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Regarding a QUERY

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

New User


Joined: 26 Oct 2007
Posts: 4
Location: chennai

PostPosted: Tue Dec 18, 2007 7:25 pm    Post subject: Regarding a QUERY
Reply with quote

Hi,

I want to retrieve DUPLICATE RECORDS from a table, Can anyone write an SQL Query for this?

Regard's
MAHESH
Back to top
View user's profile Send private message

Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Tue Dec 18, 2007 7:35 pm    Post subject:
Reply with quote

Mahesh, Can you please be specific about your requirement?
Back to top
View user's profile Send private message
arivazhagan_k

New User


Joined: 05 Dec 2007
Posts: 57
Location: chennai

PostPosted: Tue Dec 18, 2007 7:40 pm    Post subject:
Reply with quote

This topic has already posted .Please verify the previous topics .
Back to top
View user's profile Send private message
arivazhagan_k

New User


Joined: 05 Dec 2007
Posts: 57
Location: chennai

PostPosted: Tue Dec 18, 2007 7:47 pm    Post subject:
Reply with quote

Here is the link .

http://ibmmainframes.com/viewtopic.php?t=3982
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Wed Dec 19, 2007 12:07 am    Post subject: Reply to: Regarding a QUERY
Reply with quote

delete from table name where
salary in
(select salary from tablename
group by salary having count(*) > 1)


The solution provided in the above link will remove all the rows which exists more than once. (you will not only be deleting duplicates )

If you want to just delete the row occuring more than once then you may have to think of other solution.
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 Dec 19, 2007 12:37 am    Post subject:
Reply with quote

Hello,

Quote:
I want to retrieve DUPLICATE RECORDS from a table, Can anyone write an SQL Query for this?
As has been mentioned, your request is not clear. Keep in mind that you know your requirement quite clearly, but people here do not.

If you post some sample rows in a table and what you want done with them (i.e. returned from the database, deleted, etc) shown as "output", someone may have a suggestion.
Back to top
View user's profile Send private message
mahesh_valeti

New User


Joined: 26 Oct 2007
Posts: 4
Location: chennai

PostPosted: Wed Dec 19, 2007 10:52 am    Post subject: Regarding a QUERY
Reply with quote

Hi SRIHARI & DICK,

Thanks for Responding,
As u mentioned that my request is not clear, I think this will make it clear. FOR EX: Table ZAP1, it contains Columns A,B,C. Values in these columns are A B C
1 a z
2 b y
1 c x
3 e w
2 f v. What i am asking is how to write an SQL QUERY to retrieve duplicate Values from column A.

Regards,

Mahesh.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Wed Dec 19, 2007 12:51 pm    Post subject:
Reply with quote

Mahesh,
You can use the following query.
select A from tablename
group by A 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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts GETMAIN/FREEMAIN query Suja.Sai CICS 9 Tue Jan 31, 2017 12:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us