我正在尝试在 postgres 中组合两个交叉表,但卡住了,如果有人指导我,那就太好了。
-- rainfall CROSS TAB
SELECT * FROM
CROSSTAB(
'SELECT block_id, forecast_date, rainfall_mm
FROM weather.imd_forecast
ORDER BY 1'
)
AS rainfall_crosstab(
block_id int, rainfall_day_1 numeric, rainfall_day_2 numeric,
rainfall_day_3 numeric, rainfall_day_4 numeric, rainfall_day_5 numeric
);
-- temp_max CROSS TAB
SELECT * FROM
CROSSTAB(
'SELECT block_id, forecast_date, temp_max_deg_c
FROM weather.imd_forecast
ORDER BY 1'
)
AS temp_max_crosstab(
block_id int, temp_max_day_1 numeric, temp_max_day_2 numeric,
temp_max_day_3 numeric, temp_max_day_4 numeric, temp_max_day_5 numeric);