how do you count the duplicate records in a table
Answers were Sorted based on User's Feedback
Answer / priya
select coloumn_name ,count(*) from table_name
group by coloumn_name
having count(*) > 1;
| Is This Answer Correct ? | 35 Yes | 0 No |
Answer / babu
Try this,
select col1,count(col1) from tab1
group by col1 having count(col1)>1;
If you want to delete these duplicate entries, use:
delete from tab1 where col1 in (select a.col1 from
(select col1,count(col1) from tab1
group by col1 having count(col1)>1) a);
| Is This Answer Correct ? | 18 Yes | 1 No |
Answer / purushotham
select column,count(1) from a
group by column
having count(1)>1;
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / dev
Hi,
There are many ways to do it.
One of that is ,
select count(0) from tab1 a
where a.rowid > any (select b.rowid from tab1 b where
a.col1 =b.col1);
| Is This Answer Correct ? | 6 Yes | 4 No |
Answer / akki julak
select count(empno)-count(distinct(empno)) from emp;
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / ajmal khan
There are many way to count the duplicate row in a table
select count(column_name)-count(distinct(column_name)) from
table_name;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / suresh a
select sum(count(col1) -1) from emp
group by col1 having count(col1) > 1
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / shalu
select count(*) from table_name group by column1,column2...
having count(*) > 1
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / sravan
Hi here is another way to solve this
SELECT NAME, COUNT(NAME) FROM TABLE_NAME
WHERE NAME IN (SELECT NAME FROM TABLE_NAME
GROUP BY NAME
HAVING COUNT(NAME)>1)
GROUP BY NAME;
thanks
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / satheesh
SELECT COUNT(*)
FROM TABLE A
WHERE ROWID NOT IN (SELECT MAX(ROWID)
FROM TABLE B
WHERE A.COL1 = B.COL1);--UNIQUE COLUMN
| Is This Answer Correct ? | 0 Yes | 0 No |
Are sql connections encrypted?
What is posting?
Can we use loop in sql?
What is data profiling in sql?
What is a stored procedure in sql with example?
What will you get by the cursor attribute sql%rowcount?
what is outer join? what is selef join? what is difference between them? what is cartecion join?
1 Answers Fiserv, Herbinger, Synechron,
What is meant by truncate in sql?
What is varchar used for?
What are the operators used in select statements?
I have done oracle 10g. I need a project knowledge. So if u please send a project how it should be done,Or you can send email link. I will be very grateful to u.
How do I save the results of sql query in a file?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)