-- @param {String} $1:regionCode
-- @param {DateTime} $2:startDate
-- @param {DateTime} $3:endDate
SELECT
  gm.fuel_type, gm.timestamp, gm.generation_mw,
  r.code as region_code, r.name as region_name
FROM generation_mix gm
JOIN grid_regions r ON gm.region_id = r.id
WHERE r.code = $1
  AND gm.timestamp BETWEEN $2 AND $3
ORDER BY gm.timestamp ASC, gm.fuel_type
