runtime
109 / 139

task Medians, shares & ratios · medium

Debug: forecast accuracy

Return ba_code and mape_pct (2 decimals) for Q1 2024. The query divides by the forecast and lets unknown demand through. Fix it.

what to return

Columns
ba_codemape_pct in this order
Rows
12 rows · any order
Skill
Repair the query’s logic and confirm the fix on changed data. Refresher: Ratios, ROUND & NULLIF →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result12 rows · any order
ba_codemape_pct
BPAT2.27
CISO6.67
DUK2.92

first 3 of 12 rows

data you can query

Energy 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.

hourly_demand9 columns · 52,405 rows
ba_codetext · links to balancing_authoritieshour_ending_utcdate & time · unique idhour_ending_localdate & timedemand_mwnumberforecast_mwnumberlocal_datedate · links to calendarhour_numbernumberadjusted_demand_mwnumberdemand_imputednumber
BPAT2024-01-01 09:002024-01-01 01:00630263092024-01-01163020
BPAT2024-01-01 10:002024-01-01 02:00623062362024-01-01262300
BPAT2024-01-01 11:002024-01-01 03:00617962652024-01-01361790
BPAT2024-01-01 12:002024-01-01 04:00619762772024-01-01461970
BPAT2024-01-01 13:002024-01-01 05:00637863942024-01-01563780
BPAT2024-01-01 14:002024-01-01 06:00660766252024-01-01666070
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 09:00
hour_ending_localdate & time
2024-01-01 01:00
demand_mwnumber
6302
forecast_mwnumber
6309
local_datedate · links to calendar
2024-01-01
hour_numbernumber
1
adjusted_demand_mwnumber
6302
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 10:00
hour_ending_localdate & time
2024-01-01 02:00
demand_mwnumber
6230
forecast_mwnumber
6236
local_datedate · links to calendar
2024-01-01
hour_numbernumber
2
adjusted_demand_mwnumber
6230
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 11:00
hour_ending_localdate & time
2024-01-01 03:00
demand_mwnumber
6179
forecast_mwnumber
6265
local_datedate · links to calendar
2024-01-01
hour_numbernumber
3
adjusted_demand_mwnumber
6179
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 12:00
hour_ending_localdate & time
2024-01-01 04:00
demand_mwnumber
6197
forecast_mwnumber
6277
local_datedate · links to calendar
2024-01-01
hour_numbernumber
4
adjusted_demand_mwnumber
6197
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 13:00
hour_ending_localdate & time
2024-01-01 05:00
demand_mwnumber
6378
forecast_mwnumber
6394
local_datedate · links to calendar
2024-01-01
hour_numbernumber
5
adjusted_demand_mwnumber
6378
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 14:00
hour_ending_localdate & time
2024-01-01 06:00
demand_mwnumber
6607
forecast_mwnumber
6625
local_datedate · links to calendar
2024-01-01
hour_numbernumber
6
adjusted_demand_mwnumber
6607
demand_imputednumber
0

first 6 of 52,405 rows · your queries use all of them

solution.sql
 

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

Debug: forecast accuracy — SQL practice · Runtime