| delete last n sets of rows of a table with same dates in sort field [message #579828] |
Fri, 15 March 2013 15:46  |
 |
wbmoore2
Messages: 3 Registered: March 2013
|
Junior Member |
|
|
Hi. I know how to select the last N sets of rows, using DENSE_RANK - where multiple rows have the same timestamp but I want to only select those rows which do NOT have the top 2 unique timestamps.
i.e.:
SELECT *
FROM ( SELECT DENSE_RANK() OVER (ORDER BY myTimestamp DESC) DENSE_RANK, HISTORYID, USER_ID, myTimestamp, STATUS, FROM TXN_HIST)
WHERE DENSE_RANK > 2 order by myTimestamp DESC, HISTORYID, USER_ID;
But how do I DELETE these same rows?
|
|
|
|
|
|
|
|
|
|