题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
-- 解决方案(1) select distinct a.order_id, a.customer_id, a.order_type from Orders as a left join Orders as b on a.customer_id = b.customer_id and a.order_type <> b.order_type where b.order_type is null or b.order_type = 1 -- 解决方案(2) WITH t0 AS(SELECT * FROM Orders WHERE order_type = 0) SELECT * FROM Orders WHERE order_type = 1 AND customer_id NOT IN (SELECT customer_id FROM t0) UNION ALL SELECT * FROM t0