runtime
84 / 139

task GROUP BY · medium

Grid review 1: regional demand on a peak day

Find the UTC day 2024-06-20 (hours ending after 00:00 and up to 24:00). Return region_code, authorities (balancing authorities reporting) and demand_mwh (sum of known demand_mw).

what to return

Columns
region_codeauthoritiesdemand_mwh in this order
Rows
12 rows · any order
Watch for
Every stage starts from the original tables.
Use hour_ending_utc for ordering and periods; MW over one hour equals MWh.
NULL measurements are unknown: exclude them from averages and ratios, never treat them as zero.
Skill
Establish regional totals before investigating reliability. Refresher: Connect tables with JOIN →

expected result

expected result12 rows · any order
region_codeauthoritiesdemand_mwh
CAL1622208
CAR1342017
CENT1883693

first 3 of 12 rows

data you can query

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
BPAT2024-01-01 15:002024-01-01 07:00687468522024-01-01768740
BPAT2024-01-01 16:002024-01-01 08:00718970512024-01-01871890
BPAT2024-01-01 17:002024-01-01 09:00741472612024-01-01974140
BPAT2024-01-01 18:002024-01-01 10:00760374212024-01-011076030
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
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 15:00
hour_ending_localdate & time
2024-01-01 07:00
demand_mwnumber
6874
forecast_mwnumber
6852
local_datedate · links to calendar
2024-01-01
hour_numbernumber
7
adjusted_demand_mwnumber
6874
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 16:00
hour_ending_localdate & time
2024-01-01 08:00
demand_mwnumber
7189
forecast_mwnumber
7051
local_datedate · links to calendar
2024-01-01
hour_numbernumber
8
adjusted_demand_mwnumber
7189
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 17:00
hour_ending_localdate & time
2024-01-01 09:00
demand_mwnumber
7414
forecast_mwnumber
7261
local_datedate · links to calendar
2024-01-01
hour_numbernumber
9
adjusted_demand_mwnumber
7414
demand_imputednumber
0
ba_codetext · links to balancing_authorities
BPAT
hour_ending_utcdate & time · unique id
2024-01-01 18:00
hour_ending_localdate & time
2024-01-01 10:00
demand_mwnumber
7603
forecast_mwnumber
7421
local_datedate · links to calendar
2024-01-01
hour_numbernumber
10
adjusted_demand_mwnumber
7603
demand_imputednumber
0

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

balancing_authorities6 columns · 62 rows
ba_codetext · unique idba_nametexttime_zonetextregion_codetext · links to regionsgeneration_onlynumberhourly_detailnumber
AECIAssociated Electric Cooperative, Inc.CentralMIDW00
AVAAvista CorporationPacificNW00
AVRNAvangrid Renewables, LLCPacificNW10
AZPSArizona Public Service CompanyArizonaSW00
BANCBalancing Authority of Northern CaliforniaPacificCAL00
BCHABritish Columbia Hydro and Power AuthorityCAN00
BPATBonneville Power AdministrationPacificNW01
CENCentro Nacional de Control de EnergiaMEX00
CHPDPublic Utility District No. 1 of Chelan CountyPacificNW00
CISOCalifornia Independent System OperatorPacificCAL01
ba_codetext · unique id
AECI
ba_nametext
Associated Electric Cooperative, Inc.
time_zonetext
Central
region_codetext · links to regions
MIDW
generation_onlynumber
0
hourly_detailnumber
0
ba_codetext · unique id
AVA
ba_nametext
Avista Corporation
time_zonetext
Pacific
region_codetext · links to regions
NW
generation_onlynumber
0
hourly_detailnumber
0
ba_codetext · unique id
AVRN
ba_nametext
Avangrid Renewables, LLC
time_zonetext
Pacific
region_codetext · links to regions
NW
generation_onlynumber
1
hourly_detailnumber
0
ba_codetext · unique id
AZPS
ba_nametext
Arizona Public Service Company
time_zonetext
Arizona
region_codetext · links to regions
SW
generation_onlynumber
0
hourly_detailnumber
0
ba_codetext · unique id
BANC
ba_nametext
Balancing Authority of Northern California
time_zonetext
Pacific
region_codetext · links to regions
CAL
generation_onlynumber
0
hourly_detailnumber
0
ba_codetext · unique id
BCHA
ba_nametext
British Columbia Hydro and Power Authority
time_zonetext
region_codetext · links to regions
CAN
generation_onlynumber
0
hourly_detailnumber
0
ba_codetext · unique id
BPAT
ba_nametext
Bonneville Power Administration
time_zonetext
Pacific
region_codetext · links to regions
NW
generation_onlynumber
0
hourly_detailnumber
1
ba_codetext · unique id
CEN
ba_nametext
Centro Nacional de Control de Energia
time_zonetext
region_codetext · links to regions
MEX
generation_onlynumber
0
hourly_detailnumber
0
ba_codetext · unique id
CHPD
ba_nametext
Public Utility District No. 1 of Chelan County
time_zonetext
Pacific
region_codetext · links to regions
NW
generation_onlynumber
0
hourly_detailnumber
0
ba_codetext · unique id
CISO
ba_nametext
California Independent System Operator
time_zonetext
Pacific
region_codetext · links to regions
CAL
generation_onlynumber
0
hourly_detailnumber
1

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

solution.sql
 
Output

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

Grid review 1: regional demand on a peak day — SQL practice · Runtime