select ID字段,结果字段 from tabname group by ID字段,结果字段
————————————————
更新:
SELECT
C.id,
C.JG
FROM
(
SELECT
a.id,
CASE
WHEN b.id IS NOT NULL THEN
"NG"
ELSE
a.JG
END AS JG
FROM
tabname a
LEFT JOIN (
SELECT DISTINCT
ID
FROM
tabname
WHERE
JG = "NG"
) b ON a.id = b.id
) c
GROUP BY
C.id,
C.JG