Saturday, 18 January 2025

SQL very Important Questions :-

 SQL very Important Questions :-

--->--Find the Dupilcates From Table

SELECT JOB,COUNT(JOB) FROM EMP

 GROUP BY JOB

HAVING COUNT(JOB)>1;

---> Delete Duplicate From table

DELETE FROM  EMP E WHERE ROWID<> (SELECT MIN(ROWID) FROM EMP Y 

WHERE E.EMPNO=E.EMPNO);

-->dISPALY nTH SALARIES

SELECT * FROM(SELECT DENSE_RANK() OVER(ORDER BY SAL DESC)AS RNK,E.*FROM EMP E)

WHERE RNK=1;

Select * from emp where Rownum <= 5;

select rownum, e.* from emp e where rownum<=(select count(*)/2 from emp);

--->

select distinct A.empno, A.ename,a.sal,b.sal, A.mgr, B.empno, B.ename

from EMP A, EMP B where A.mgr = B.empno and A.sal > B.sal ;


No comments:

Post a Comment

Scinario Based interview Question .....

 How  To Achieve The Scenario. Input File1.csv  id,Name 1,Mahendra File2.csv City, State Hyd,Telangana File3.csv Stateid Ts I want Out put F...