Re: Delete First 3 and Last 3 Rows in Target Table
Kindly use below query, it might fullfill the requirement.....
DELETE FROM EMP_TEMP
WHERE EMPNO IN (
SELECT EMPNO
FROM EMP_TEMP
WHERE ROWNUM <= 3 UNION
SELECT EMPNO
FROM (SELECT *
FROM EMP_TEMP
ORDER BY EMPNO DESC)
WHERE ROWNUM <= 3
);
Explanation :
1. Select stmt. in Blue color will select 1st three row from top.
2. Select stmt. in green will select employees just in reverse order from which three upper rows will be selected using rownum <= 3
3. Union of both will pass top three + bottom three employee nos.