Drivers With Low or No Tips
Problem
Table: `Driver`
```text
+----------+---------+
| Column | Type |
+----------+---------+
| driver_id| int |
| name | varchar |
| city | varchar |
+----------+---------+
driver_id is the primary key.
```
Table: `Tip`
```text
+----------+------+
| Column | Type |
+----------+------+
| driver_id| int |
| amount | int |
+----------+------+
driver_id is the primary key and references Driver.driver_id. Each row is the total tip a driver collected in a shift.
```
Report the `name` and tip `amount` of every driver who either earned a tip of **less than** `20`, or received **no tip at all**. Return the rows in any order.
**Example**
```text
Driver:
+-----------+-------+--------+
| driver_id | name | city |
+-----------+-------+--------+
| 3 | Omar | Haifa |
| 1 | Lea | Acre |
| 2 | Dana | Acre |
| 4 | Yossi | Eilat |
+-----------+-------+--------+
Tip:
+-----------+--------+
| driver_id | amount |
+-----------+--------+
| 2 | 8 |
| 4 | 35 |
+-----------+--------+
Output:
+-------+--------+
| name | amount |
+-------+--------+
| Omar | null |
| Lea | null |
| Dana | 8 |
+-------+--------+
```
Tables
Example rows — the live problem includes the full dataset.
| driver_id | name | city |
|---|---|---|
| 3 | Omar | Haifa |
| 1 | Lea | Acre |
| 2 | Dana | Acre |
| driver_id | amount |
|---|---|
| 2 | 8 |
| 4 | 35 |
Expected output
Your answer should return 3 rows with the columns name, amount.
Starter code (SQL)
SELECT *
FROM Driver;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock