with ID as (SELECT id, report_type, ROW_NUMBER() OVER(PARTITION BY report_type ORDER BY id DESC) as 'RowNum' from tablename) SELECT id,report_type FROM ID WHERE RowNum <= 3
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)