runtime
102 / 139

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_zero in 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

trip_sample2 columns · 6 rows
trip_idpassenger_count
201
213
221
23NULL
242
252
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

predict.sql
SELECT
  ROUND(AVG(passenger_count), 2) AS avg_known,
  ROUND(AVG(COALESCE(passenger_count, 0)), 2) AS avg_as_zero
FROM trip_sample
prediction.json

Enter the rows you think the query returns, column order avg_known, avg_as_zero. JSON array of rows — numbers bare, text in quotes, null for NULL. Example: [ [ 1, null ] ]. Keep ORDER BY order.

 
Output

Hints and the answer are always available. Using them counts the question as solved with help.

Predict: missing passenger counts in an average — SQL practice · Runtime