I'm trying to combine two crosstab in postgres but stuck it will be great if someone guide me.
-- 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);
CREATE TABLE
statement) , sample data (INSERT
), and the desired output. Text, no images. A couple of rows will do. Why are there exactly 5 days in the output?