请尝试使用以下查询:
WITH YOUR_TABLE_DATA (service_code,row_status,business_unit_id)AS
(
SELECT 'A', 1, 'BU1' UNION ALL
SELECT 'A' , 0, 'BU2' UNION ALL
SELECT 'A' , 0, 'BU3' UNION ALL
SELECT 'B', 1, 'BU1' UNION ALL
SELECT 'B', 0, 'BU2' UNION ALL
SELECT 'C', 0, 'BU2' UNION ALL
SELECT 'C' , 0, 'BU3'
)
SELECT C.service_code
FROM YOUR_TABLE_DATA AS C
GROUP BY C.service_code
HAVING MIN(C.row_status)=MAX(C.row_status)
AND MIN(C.row_status)=0