SQL template for all MHW metrics
metric_by_decade_sql.RdTHIS will divide up a date range into 10 year periods only. For a function that can do any length period (2, 5, 10, 20, 30 yrs, etc), see mhw_metric_summary_sql() in mhw_summary.R
Usage
metric_by_decade_sql(
  mhw_table,
  mhw_metric = "int_mean",
  sql_function = "avg",
  start_year = 2040,
  end_year = 2069,
  ensemble_list_string = NA
)Arguments
- mhw_table
 name of the table to use
- mhw_metric
 character name of column in table, mhw_dur, int_mean, etc
- start_year
 integer year to start, inclusive (dates will include this start year)
- end_year
 integer year to end, inclusive (dates will include up to 12/31 of the end year)
- ensemble_list_string
 character string that is a list of ensembles to include in format "006,007,008" ensembles have leaving zeros, are 3 digits and this must be a separated list with leading zeros
- sqlfun
 character aggregate function for duckdb, see https://duckdb.org/docs/sql/functions/aggregates