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
 
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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm

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