Let's assume I extract some set of data.
i.e.
SELECT A, date
FROM table
I want just the record with the max date (for each value of A). I could write
SELECT A, col_date
FROM TABLENAME t_ext
WHERE col_date = (SELECT MAX (col_date)
FROM TABLENAME t_in
WHERE t_in.A = t_ext.A)
But my query is really long... is there a more compact way using ANALYTIC FUNCTION to do the same?
TABLENAME
that had the same value forA
and the same value forSOME_DATE_COLUMN
. Your original query would return both of those rows as would mine. If, on the other hand, you used theROW_NUMBER
function, only one of the two rows would be returned (though the choice of which row to return would be arbitrary). – Blisse