15 lines
787 B
JavaScript
15 lines
787 B
JavaScript
function getAllRegionsWithClimatePerMonth(month) {
|
|
console.log('getAllRegionsWithClimatePerMonth')
|
|
const sql = `SELECT
|
|
region_climate.region_id AS region_id,
|
|
regions.country_id AS country_id,
|
|
regions.region AS name,
|
|
ROUND(AVG(region_climate.temperature_mean), 1) AS temperature_mean,
|
|
ROUND(AVG(region_climate.temperature_mean_min), 1) AS temperature_mean_min,
|
|
ROUND(AVG(region_climate.temperature_mean_max), 1) AS temperature_mean_max,
|
|
ROUND(AVG(region_climate.percipitation), 1) AS percipitation,
|
|
ROUND(AVG(region_climate.raindays), 1) AS raindays,
|
|
ROUND(AVG(region_climate.sunshine), 1) AS sunhours
|
|
FROM region_climate JOIN regions ON region_climate.region_id = regions.id WHERE region_climate.month = ${month} GROUP BY region_id`
|
|
return getQueryRows(sql)
|
|
} |