runtime
105 / 139

task UNION / INTERSECT / EXCEPT · medium

Predict: duplicate values in a set

Predict both counts for the fuel lists of two authorities on one day.

what to return

Columns
union_rowsunion_all_rows 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: Combine sets with UNION →

data you can query

fuel_sample2 columns · 16 rows
ba_codefuel_code
ISNECOL
ISNENG
ISNENUC
ISNEOIL
ISNEOTH
ISNESUN
ISNEWAT
ISNEWND
NYISCOL
NYISNG
ba_code
ISNE
fuel_code
COL
ba_code
ISNE
fuel_code
NG
ba_code
ISNE
fuel_code
NUC
ba_code
ISNE
fuel_code
OIL
ba_code
ISNE
fuel_code
OTH
ba_code
ISNE
fuel_code
SUN
ba_code
ISNE
fuel_code
WAT
ba_code
ISNE
fuel_code
WND
ba_code
NYIS
fuel_code
COL
ba_code
NYIS
fuel_code
NG

first 10 of 16 rows · your queries use all of them

predict.sql
SELECT
  (
    SELECT COUNT(*)
    FROM (
      SELECT fuel_code
      FROM fuel_sample
      WHERE ba_code = 'ISNE'
      UNION
      SELECT fuel_code
      FROM fuel_sample
      WHERE ba_code = 'NYIS'
    )
  ) AS union_rows,
  (
    SELECT COUNT(*)
    FROM (
      SELECT fuel_code
      FROM fuel_sample
      WHERE ba_code = 'ISNE'
      UNION ALL
      SELECT fuel_code
      FROM fuel_sample
      WHERE ba_code = 'NYIS'
    )
  ) AS union_all_rows
prediction.json

Enter the rows you think the query returns, column order union_rows, union_all_rows. 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: duplicate values in a set — SQL practice · Runtime