![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Super Moderator Join Date: Feb 2006
Posts: 2,379
Blog Entries: 4 Thanks: 118
Thanked 319 Times in 238 Posts
Rep Power: 60 | Hi All, I have a table "MyTable" with a primary column called "SNO". Let the other columns called A,B,C and D. There is some data in the table. I want to know if there are any duplicate records. But, as SNO field is generated & inserted by a trigger, there is no chance that it will have a duplicate value. So, we have to compare other columns to get the duplicate records. I want to know the query which I can use to know the records those were duplicates of others. Thanks, Krishna
__________________ Looking for trainees for a start up company |
| | |
| | #2 (permalink) |
| Senior Member Join Date: Apr 2006 Location:
Posts: 151
Thanks: 0
Thanked 8 Times in 5 Posts
Rep Power: 5 | Hi Krishna SELECT A,B,C,D, count(*) FROM MyTable GROUP BY A,B,C,D HAVING count(*) > 1 This query should help you identify the duplicate rows. This would group all the records with the values of columns A,B,C and D and then count the no. of rows in that group. If the Count is more than1 then its a duplicate. Hope this helps. Sangeetha Edited by: jsangeetha |
| | |
| | #3 (permalink) |
| Super Moderator Join Date: Feb 2006
Posts: 2,379
Blog Entries: 4 Thanks: 118
Thanked 319 Times in 238 Posts
Rep Power: 60 | Hi Sangeetha, Thanks for the reply!!! Going forward, I have copied the same table onto another DB. But, it is on different character set. So, some characters were interpreted as special characters while copying data. Now I want to know which are the rows those have the changed charaters. I mean the rows that don't match with the old one. query used to copy table onto new DB is create table mytable as (select * from mytable@old_db); NOTE: "old_db" is the DB connection I have in new DB to connect to my old DB. Thanks, Krishna
__________________ Looking for trainees for a start up company |
| | |
![]() |
| Tags |
| duplicate , records , sql |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| More Interview Questions Here... |