Resampling Time-Series Data
The example below shows how to resample data to longer intervals using tables available in our Snowflake Marketplace Listing. You can use the same approach with other datasets, such as converting 5-minute data to hourly averages. Choose an aggregation that fits the data: for example, average prices or sum interval energy.
Hourly Average Prices
We can calculate hourly average settlement point prices (SPP) from ERCOT SPP Real Time 15 Min by averaging the four 15-minute prices in each hour. Prices are in $/MWh.
This query returns all settlement points starting at the beginning of the hour 24 hours ago, including the current partial hour.
WITH hourly AS (
SELECT
DATE_TRUNC('hour', interval_start_utc) AS interval_start_utc,
location,
location_type,
AVG(spp) AS spp
FROM
ercot_spp_real_time_15_min
GROUP BY
DATE_TRUNC('hour', interval_start_utc),
location,
location_type
)
SELECT
interval_start_utc,
DATEADD('hour', 1, interval_start_utc) AS interval_end_utc,
CONVERT_TIMEZONE('America/Chicago', interval_start_utc) AS interval_start_local,
CONVERT_TIMEZONE(
'America/Chicago', DATEADD('hour', 1, interval_start_utc)
) AS interval_end_local,
location,
location_type,
spp
FROM
hourly
WHERE
interval_start_utc >= DATEADD(
'hour', -24, DATE_TRUNC('hour', CURRENT_TIMESTAMP())
)
ORDER BY
interval_start_utc,
location,
location_type;The query averages each location and location type separately. It groups intervals into UTC hours, then converts the timestamps to ERCOT's local time (America/Chicago). This keeps the repeated hour when daylight saving time ends separate, with a different UTC offset for each occurrence.
AVG(spp) ignores null prices. If an hour has fewer than four prices, the query averages the available values. Hours with no source rows are not returned.
Last updated
Was this helpful?

