Reply to Re: Query/View: The 2 newest periods for each indicator
Posted by Alexander Kuznetsov on 04/15/06 20:23
if it is SQL Server 2005, use row_number() *untested*:
select * from(
SELECT table1.kpiID, table1.periodID, table1.Actual,
row_number() over(partition by kpId order by periodId desc) rn
FROM table1
) t
where rn<3