File tree 2 files changed +22
-0
lines changed
solution/2000-2099/2084.Drop Type 1 Orders for Customers With Type 0 Orders
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -92,4 +92,15 @@ FROM Orders AS o
92
92
WHERE order_type = 0 OR NOT EXISTS (SELECT 1 FROM T AS t WHERE t .customer_id = o .customer_id );
93
93
```
94
94
95
+ ``` sql
96
+ SELECT DISTINCT
97
+ a .order_id ,
98
+ a .customer_id ,
99
+ a .order_type
100
+ FROM
101
+ Orders AS a
102
+ LEFT JOIN Orders AS b ON a .customer_id = b .customer_id AND a .order_type != b .order_type
103
+ WHERE b .order_type IS NULL OR b .order_type = 1 ;
104
+ ```
105
+
95
106
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -88,4 +88,15 @@ FROM Orders AS o
88
88
WHERE order_type = 0 OR NOT EXISTS (SELECT 1 FROM T AS t WHERE t .customer_id = o .customer_id );
89
89
```
90
90
91
+ ``` sql
92
+ SELECT DISTINCT
93
+ a .order_id ,
94
+ a .customer_id ,
95
+ a .order_type
96
+ FROM
97
+ Orders AS a
98
+ LEFT JOIN Orders AS b ON a .customer_id = b .customer_id AND a .order_type != b .order_type
99
+ WHERE b .order_type IS NULL OR b .order_type = 1 ;
100
+ ```
101
+
91
102
<!-- tabs:end -->
You can’t perform that action at this time.
0 commit comments