IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Regarding a QUERY


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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

Moderator Emeritus


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

PostPosted: Wed Dec 19, 2007 12:37 am
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top