Wybierz tylko jeden dla każdego odrębnego koloru, niezależnie od innych kolumn
WITH cte AS
( SELECT *, ROW_NUMBER() OVER (PARTITION BY id ORDER BY val1 DESC) AS rn
FROM MyTable
)
SELECT *
FROM cte
WHERE rn = 1
MonkeySeeMonkeyDo