task NULL handling · medium
Predict: missing passenger counts in an average
Predict the two averages over the sample trips.
what to return
- Columns
avg_knownavg_as_zeroin this order- Rows
- in the order asked
- Watch for
- Use only the sample rows shown. NULL is not zero or empty text. Keep duplicate rows.
- Skill
- Reason about the exact result of a fixed SQL query. Refresher: COUNT, SUM & AVG →
data you can query
Mobility dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.
trip_sample2 columns · 6 rows
| trip_id | passenger_count |
|---|---|
| 20 | 1 |
| 21 | 3 |
| 22 | 1 |
| 23 | NULL |
| 24 | 2 |
| 25 | 2 |
- trip_id
- 20
- passenger_count
- 1
- trip_id
- 21
- passenger_count
- 3
- trip_id
- 22
- passenger_count
- 1
- trip_id
- 23
- passenger_count
- NULL
- trip_id
- 24
- passenger_count
- 2
- trip_id
- 25
- passenger_count
- 2
all 6 rows
SELECT ROUND(AVG(passenger_count), 2) AS avg_known, ROUND(AVG(COALESCE(passenger_count, 0)), 2) AS avg_as_zero FROM trip_sample
SELECT ROUND(AVG(passenger_count), 2) AS avg_known, ROUND(AVG(COALESCE(passenger_count, 0)), 2) AS avg_as_zero FROM trip_sample
Look at the sample tables and SQL. Enter the rows you think the query returns, in this column order: avg_known, avg_as_zero. Put each row in square brackets, then wrap all rows in another pair of brackets (JSON format). For example, [[1,null]] is one row with 2 values. Replace these with your predicted values. Use numbers without quotes, text in double quotes, and null for SQL NULL. Keep repeated rows. Use [] for no rows. Keep rows in the order specified by ORDER BY.
Hints and the answer are always available. Using them counts the question as solved with help.