Krishna Logo
qa training in canada now
Divied
Call: Anusha @ 1 (877) 864-8462

 

Latest News
Home Navigation Divied
DATABASE Navigation Divied SQL Navigation Divied Working with duplicate rows
Working With Duplicate Rows
Working with duplicate rows

'select the count from two tables

select (select count(*) from emp) as count1,(select count (*)  from empnew5) count2 from dual
++++++++++++++++++++++++++++++++++++++++++

'HOW TO ELIMINATE DUPLICATE ROWS WHILE DISPLAYING THE DATA

select distinct * from empnew where ename in

(SELECT ename FROM empnew GROUP BY ename HAVING ( COUNT(ename) > 1 or COUNT(ename)=1))

++++++++++++++++++++++++++++++++++++++++

'select the count from two tables

select (select count(*) from emp) as count1,(select count (*)  from empnew5) count2 from dual

+++++++++++++++++++++++++++++++++++++++++++

select distinct empno,ename,sal,deptno,mgr from empnew where empno in

         (SELECT empno FROM empnew GROUP BY empno HAVING ( COUNT(empno) > 1 ))

++++++++++++++++++++++++++++++++++++++++++++

SELECT ename,sal,count(*) NoOfOccurences FROM empnew GROUP BY ename HAVING ( COUNT(ename) > 1 )

SELECT ename FROM empnew GROUP BY ename HAVING ( COUNT(ename) > 1 )

+++++++++++++++++++++++++++++++++++++++++

select distinct * from empnew where ename in

(SELECT ename FROM empnew GROUP BY ename HAVING ( COUNT(ename) > 1 ))

+++++++++++++++++++++++++++++++++++++++++++

'HOW TO ELIMINATE DUPLICATE ROWS WHILE DISPLAYING THE DATA

select distinct * from empnew where ename in

(SELECT ename FROM empnew GROUP BY ename HAVING ( COUNT(ename) > 1 or COUNT(ename)=1))

select min(rowid)from empnew2 group by ename

delete from empnew2 where rowid not in(select min(rowid)from empnew2 group by ename)

CREATE TABLE EMPNEW3 AS selecT * FROM EMPNEW

+++++++++++++++++++++++++++++++++++++++

select distinct empno,ename,sal,deptno,mgr from empnew where empno in

         (SELECT empno FROM empnew GROUP BY empno HAVING ( COUNT(empno) > 1 ))

SELECT empno FROM empnew GROUP BY empno HAVING ( COUNT(empno) = 1 )

+++++++++++++++++++++++++++++++++++++++

'intersect will display the common rows between the two tables

select * from empnew intersect select * from empnew5

+++++++++++++++++++++++++++++++

'select the count from two tables

select (select count(*) from emp) as count1,(select count (*)  from empnew5) count2 from dual


Shadow Bottom
 
 
© 2005 -