RE: Now suppose i have 50 records of employee table.
Hi
For the 1st Question: Ans:- Select a.sal from emp a where 29 (select count(distinct(b.sal)) from emp b Where a.sal< b.sal) For the 2nd Question: Ans:-Delete from Employee where Positionnumber 39 and Commission<100; For the 3rd Question: And:-update employee set recno 45;
RE: Now suppose i have 50 records of employee table.1) I want to find the person who is having 22nd highest salary.2)i want to delete a person with postion number 39 with comminsion < 1003) Update rec no 45records are not shown.how do i do it.
Ans 1: (works only for db2 for oracle use rownum())
SELECT EMP_NAME SAL FROM (SELECT EMP_NAME SAL ROWNUMBER() OVER (ORDER BY SAL desC) AS RN FROM EMP) A WHERE A.RN 22
Ans 2 : Question is not clear.
delete from emp where positionnumber 39 and commission<100;
Ans 3: Update rec no 45
UPDATE EMP SET EMP_NAME 'XYZ' WHERE EMP_NAME (SELECT EMP_NAME FROM (SELECT EMP_NAME SAL ROWNUMBER() OVER (ORDER BY EMP_NO ASC) AS RN FROM EMP) A WHERE A.RN 45)