Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to do group by with the rowid

689201Apr 8 2009 — edited Apr 8 2009
CREATE OR REPLACE PROCEDURE DELETE_RECS
AS

BEGIN
DELETE FROM x
WHERE x_date < SYSDATE - 30
AND ROWID NOT IN (SELECT rid
FROM (SELECT ROWID AS rid
FROM x
ORDER BY x_date DESC)
WHERE ROWNUM <= 10);
END;

have to delete the values in the following scnerious. like

group by. e.g

e.g in a table there are group of values say

444 - having 20 rows
555 - having 15 rows
666 - having 17 rows.

should get the result as

444-10 rows with recent dates
555-10 rows with recent dates
666 - 10 rows with recent dates

but the above query deletes only on date. need help to do group by in the inner query

group by x.columnname1,x.columnname2 in the above query
This post has been answered by Manuel Vidigal on Apr 8 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2009
Added on Apr 8 2009
2 comments
1,869 views