How to retrieve Duplicate Rows only in a Table?
Suppose if a Table Name is "Education". It consists of
multiple columns. Then if we insert rows into this table
with duplicate records then how can we retrieve only
duplicate records from that table?
Answers were Sorted based on User's Feedback
Answer / lakshmi narayana
select * from emp a ,
(select empno,count(*) from emp group by empno having count
(*) > 1) b
where a.empno = b.empno
Is This Answer Correct ? | 27 Yes | 10 No |
Answer / kalaiselvan.j
select count(*),column_name from table_name group by
column_name having count(*)>1
Is This Answer Correct ? | 14 Yes | 0 No |
Answer / smita
select a.empno, a.empname from education a,
(select empno, count(*) cnt from education group by empno
having count(*) > 1) b
where a.empno = b.empno
is the correct answer
Is This Answer Correct ? | 12 Yes | 5 No |
Answer / cesar di sanctis
select * from <table_name>
where <column_name> in
(select <column_name>
from <table_name>
group by <column_name>
having count(*) > 1)
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / lakshmi
In the above query we have to add distinct before *. Else
duplicate rows will be fetched twice.
Thanks,
Lakshmi
Is This Answer Correct ? | 9 Yes | 4 No |
Answer / seshu
SELECT RNO,NAME,COUNT(*) REP_COL FROM Education GROUP BY
RNO,NAME having Count(*)>1;
Is This Answer Correct ? | 7 Yes | 3 No |
Answer / amit
select * from taruntest1 b where rowid not in (select min
(rowid) from taruntest1 a where a.a=b.a );
Is This Answer Correct ? | 8 Yes | 5 No |
Answer / balaji
For Sample:
----------
select count(pmid) as Occurances,pmid from tablename group
by pmid having count(pmid)>1
Is This Answer Correct ? | 7 Yes | 5 No |
Answer / rajesh kumar patnaik
SELECT ProductName
FROM Products
WHERE (ProductName IN
(SELECT ProductName
FROM Products
GROUP BY ProductName
HAVING COUNT(*) > 1))
Is This Answer Correct ? | 8 Yes | 6 No |
Answer / aravind
select SPAN_UUID, SPAN_UNIT_UUID, count(*) from
SPAN_SPAN_UNIT group by SPAN_UUID, SPAN_UNIT_UUID having
count(*) > 1;
Is This Answer Correct ? | 4 Yes | 2 No |
what are the drivers in mysql? : Sql dba
What is use of package in pl sql?
Wat is SGA ?
can we call a procedure into another procedure?If yes means how you can pass the perameters for the two procedures?
Explain the difference between rename and alias?
what are the advantages of primary key over unique+notnull
7 Answers Consultancy, LGS, Oracle,
source destination distance chennai bangalore 500 bangalore chennai 500 hyd delhi 1000 delhi hyd 1000 bangalore hyd 800 Here chennai to bangalore and bangalore to chennai is same distance. and hyd and delhi also same criteria. Based on the distance i want to display only one row using sql query?
What is a relationship and what are they?
Does a user_objects view have an entry for a trigger?
What is the difference between join and natural join?
how to enter binary numbers in sql statements? : Sql dba
what is inline view?