I know you can use TOP x to retrieve the first x records from a table, but how do you get the first x records from within a group?For example, if I had a table as follows:Category Ranking========== =======Category 1 3Category 1 5Category 1 4Category 1 10Category 2 1Category 2 5Category 2 3Category 3 20Category 3 5Category 3 7Category 3 18Category 3 15Category 3 10Category 3 5
and I want to select get the top 2 rankings for each category, I would want the output to be:Category Ranking========== =======Category 1 10Category 1 5Category 2 5Category 2 3Category 3 20Category 3 18
Many thanks for any help!