runtime
101 / 139

task Conditional aggregation · medium

Predict: integer and decimal ratios

Predict both forecast ratios for the two sample authorities.

what to return

Columns
ba_codeint_ratioreal_ratio 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: Ratios, ROUND & NULLIF →

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.

forecast_sample3 columns · 2 rows
ba_codedemand_mwforecast_mw
ISNE96188700
NYIS1442613881
ba_code
ISNE
demand_mw
9618
forecast_mw
8700
ba_code
NYIS
demand_mw
14426
forecast_mw
13881

all 2 rows

predict.sql
SELECT
  ba_code,
  demand_mw / forecast_mw AS int_ratio,
  ROUND(1.0 * demand_mw / forecast_mw, 3) AS real_ratio
FROM forecast_sample
ORDER BY ba_code
Read the query · predict its result
SELECT ba_code, demand_mw / forecast_mw AS int_ratio, ROUND(1.0 * demand_mw / forecast_mw, 3) AS real_ratio FROM forecast_sample ORDER BY ba_code

Look at the sample tables and SQL. Enter the rows you think the query returns, in this column order: ba_code, int_ratio, real_ratio. Put each row in square brackets, then wrap all rows in another pair of brackets (JSON format). For example, [[1,null,null]] is one row with 3 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.

Predict: integer and decimal ratios — SQL practice · Runtime