@@ -94,40 +94,72 @@ and t.Request_at between '2013-10-01' and '2013-10-03'
94
94
group by t .Request_at ;
95
95
```
96
96
97
- 12 . [ ] ( )
97
+ 12 . [ Find Customer Referee ] ( https://leetcode.com/problems/find-customer-referee/ )
98
98
``` SQL
99
+ select name from customer where referee_id <> 2 OR referee_id IS NULL
99
100
```
100
101
101
- 13 . [ ] ( )
102
+ 13 . [ Customer Placing the Largest Number of Orders ] ( https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/ )
102
103
``` SQL
104
+ select customer_number from orders
105
+ group by customer_number
106
+ order by count (order_number) desc limit 1 ;
103
107
```
104
108
105
- 14 . [ ] ( )
109
+ 14 . [ Big Countries ] ( https://leetcode.com/problems/big-countries/ )
106
110
``` SQL
111
+ select name, population, area from world
112
+ where area >= 3000000 or population >= 25000000
107
113
```
108
114
109
- 15 . [ ] ( )
115
+ 15 . [ Sales Person ] ( https://leetcode.com/problems/sales-person/ )
110
116
``` SQL
117
+ SELECT name from salesperson
118
+ where sales_id not in
119
+ (
120
+ select sales_id from orders where com_id in
121
+ (select com_id from company where name= ' RED' )
122
+ )
111
123
```
112
124
113
- 16 . [ ] ( )
125
+ 16 . [ Tree Node ] ( https://leetcode.com/problems/tree-node/ )
114
126
``` SQL
127
+ SELECT id,
128
+ IF (p_id IS NULL , " Root" ,
129
+ IF (id IN (SELECT p_id FROM Tree), " Inner" , " Leaf" )
130
+ ) AS type
131
+ FROM Tree
115
132
```
116
133
117
- 17 . [ ] ( )
134
+ 17 . [ Swap Salary ] ( https://leetcode.com/problems/swap-salary/ )
118
135
``` SQL
136
+ UPDATE salary SET sex = IF(sex = ' m' , ' f' , ' m' )
119
137
```
120
138
121
- 18 . [ ] ( )
139
+ 18 . [ Actors and Directors Who Cooperated At Least Three Times ] ( https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/ )
122
140
``` SQL
141
+ select actor_id, director_id
142
+ from ActorDirector
143
+ group by actor_id, director_id
144
+ having count (timestamp ) > 2
123
145
```
124
146
125
- 19 . [ ] ( )
147
+ 19 . [ Sales Analysis III ] ( https://leetcode.com/problems/sales-analysis-iii/ )
126
148
``` SQL
149
+ SELECT s .product_id , product_name
150
+ FROM Sales s
151
+ LEFT JOIN Product p
152
+ ON s .product_id = p .product_id
153
+ GROUP BY s .product_id
154
+ HAVING MIN (sale_date) >= CAST(' 2019-01-01' AS DATE ) AND
155
+ MAX (sale_date) <= CAST(' 2019-03-31' AS DATE )
127
156
```
128
157
129
- 20 . [ ] ( )
158
+ 20 . [ Game Play Analysis I ] ( https://leetcode.com/problems/game-play-analysis-i/ )
130
159
``` SQL
160
+ select player_id, min (event_date) as first_login
161
+ from activity
162
+ group by player_id
131
163
```
132
164
133
165
. [ ] ( )
0 commit comments