Вероятно имате нужда от това:
SELECT
MIN(id) id,
code,
MIN(product_name) product_name,
MIN(supplier) supplier
FROM
yourtable
WHERE
(code, CASE WHEN supplier='Supplier1' THEN '' ELSE supplier END)
IN (SELECT code, min(CASE WHEN supplier='Supplier1' THEN '' ELSE supplier END)
FROM yourtable
GROUP BY code)
GROUP BY
code
ORDER BY
min(id);
Моля, вижте fiddle тук .