This is a terrible way to do this because of the row by row RBAR comparison but it was the only way I could figure out (in between real work tasks) :)set nocount ondeclare @tbl table (materialName varchar(100), YR int, qty int)insert into @tbl (materialName, YR, qty)select 'stuff', 2005, 10 union allselect '1stuff', 2005, 10 union allselect '1stuff', 2005, 10 union allselect '2stuff', 2005, 10 union allselect '2stuff', 2005, 10 union allselect '2stuff', 2005, 10 union allselect '3stuff', 2005, 10 union allselect '3stuff', 2005, 10 union allselect '3stuff', 2005, 10 union allselect '3stuff', 2005, 10 union allselect 'stuff', 2006, 10 union allselect '1stuff', 2006, 10 union allselect '1stuff', 2006, 10 union allselect '2stuff', 2006, 10 union allselect '2stuff', 2006, 10 union allselect '2stuff', 2006, 10 union allselect '3stuff', 2006, 10 union allselect '3stuff', 2006, 10 union allselect '3stuff', 2006, 10 union allselect '3stuff', 2006, 10 union allselect '4stuff', 2006, 10 union allselect '4stuff', 2006, 10 union allselect '4stuff', 2006, 10 union allselect '4stuff', 2006, 10 union allselect '4stuff', 2006, 10 union allselect '4stuff', 2006, 10 -- The query will return the top 2 performers for each fiscal yrselect D.materialName, D.yr, D.sumQty from ( select materialName, Yr, sum(qty) as sumQTY from @tbl group by materialName, YR) D where ( select count(X.materialName) from ( select materialName, Yr, sum(qty) as sumQTY from @tbl group by materialName, YR ) X where X.yr = D.yr and X.sumQTY >= D.sumQTY) <= 2 order by D.yr, D.sumQTY desc, D.materialName
God Bless