Monday, March 31, 2008

return the recent record(max(last_run_date)) of distinct rows within a table

This will return the recent record(max(last_run_date)) of distinct application_type

SELECT *
FROM (SELECT status, application_type, failure_reason, last_run_date,
application_run_seq,
ROW_NUMBER () OVER (PARTITION BY application_type ORDER BY last_run_date DESC,
application_type) AS control_rank
FROM control_test)
WHERE control_rank <= 1

No comments: