this can be done with a corelated subquery. There may be better ways - I am not as much of a sql god as some of the regulars on this forum
Here I am assuming you have an int pk column, I named it "id":declare @t table (id int, EmployeeNum int, DateofInvoice datetime, Cost int)insert into @t select 1, 1, '2006-01-01', 12 union allselect 2, 1, '2006-02-01', 13 union allselect 3, 1, '2006-03-01', 14 union allselect 4, 1, '2006-04-01', 15 union allselect 5, 1, '2006-05-01', 16 union allselect 6, 2, '2006-06-01', 17 union allselect 7, 2, '2006-07-01', 18 union allselect 8, 2, '2006-08-01', 19 union allselect 9, 2, '2006-09-01', 20select * from @t tt where id in ( select top 3 id from @t where EmployeeNum = tt.EmployeeNum order by DateofInvoice desc)
SqlSpec - a fast, cheap, and comprehensive data dictionary generator forSQL Server 2000/2005 and Analysis Server 2005 - http://www.elsasoft.org