View previous topic :: View next topic
|
Author |
Message |
mahesh_valeti
New User
Joined: 26 Oct 2007 Posts: 4 Location: chennai
|
|
|
|
Hi,
I want to retrieve DUPLICATE RECORDS from a table, Can anyone write an SQL Query for this?
Regard's
MAHESH |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Mahesh, Can you please be specific about your requirement? |
|
Back to top |
|
|
arivazhagan_k
New User
Joined: 05 Dec 2007 Posts: 57 Location: chennai
|
|
|
|
This topic has already posted .Please verify the previous topics . |
|
Back to top |
|
|
arivazhagan_k
New User
Joined: 05 Dec 2007 Posts: 57 Location: chennai
|
|
Back to top |
|
|
vini_srcna
Active User
Joined: 26 May 2005 Posts: 178 Location: Copenhagen, Denmark
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
mahesh_valeti
New User
Joined: 26 Oct 2007 Posts: 4 Location: chennai
|
|
|
|
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 |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Mahesh,
You can use the following query.
select A from tablename
group by A having count(*) > 1 |
|
Back to top |
|
|
|