Here is what my data looks like:
item_ID | group_ID | count_of_items_in_group
2|ABC|3
5|ABC|3
9|ABC|3
29|DEF|3
3|DEF|3
4|DEF|3
200|XYZ|2
300|XYZ|2
6
What about using ROW_NUMBER() to enum the number of fields of your data set, partitioned by each group_id.
And after that just return when is just less or equal to 2? or any number that you want
SELECT * FROM
(
select item_id, group_id, count_of_items,
ROW_NUMBER() OVER(PARTITION BY group_id ORDER BY count_of_items DESC)
AS RN
from items_in_groups
) A
WHERE RN <= 2
Here is the Sql Fiddle