CREATE TABLE #TEMP(Group_ID int, Product_ID int, Is_Prime_Product char(10));
INSERT INTO #TEMP VALUES
(1,2,'false'),
(1,1,'true '),
(1,3,'false'),
(1,4,'false'),
(2,3,'false'),
(2,1,'true'),
(2,2,'false'),
(3,2,'false'),
(3,3,'true'),
(3,1,'false');
SELECT Group_ID,Product_ID,Is_Prime_Product
FROM #TEMP
GROUP BY Group_ID,Product_ID,Is_Prime_Product
ORDER BY Group_ID,Is_Prime_Product DESC
--------------------------------------------------
Group_ID Product_ID Is_Prime_Product
--------------------------------------------------
1 1 true
1 2 false
1 3 false
1 4 false
2 1 true
2 2 false
2 3 false
3 3 true
3 1 false
3 2 false