AnalystPath

Drivers With Low or No Tips

SQLEasyJunior level~15 min

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
driver_idnamecity
3OmarHaifa
1LeaAcre
2DanaAcre
Tip
driver_idamount
28
435

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

Related SQL questions