Wednesday, February 10, 2010

Important SQL Queries

1)How to delete Duplicate rows in a Table ?

DELETE from table_name A WHERE ROWID>(SELECT min(ROWID) from table_name B WHERE A.Col_name=B.Col_name)

2)How to Identify Duplicates in a Table ?

Select Col1,Col2,Col3....... from table_name GROUP BY Col1,Col2,Col3....Having Count(*)>1;

3)To get Top Five Salary Employee Details ?

Select * from (Select * from table_name ORDER BY Salary Desc) WHERE ROWNUM<=5;

No comments:

Post a Comment