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