The following redshift query is showing the data as screenshot in below:
select
distinct id_butaca,
max(CASE WHEN id_tipoorden = 1 THEN fechahoracompra ELSE NULL END) over (partition by id_butaca,id_tipoorden ) as max_fecha_compra,
max(CASE WHEN id_tipoorden = 4 THEN fechahoracompra ELSE NULL END) over (partition by id_butaca,id_tipoorden ) as max_fecha_devo
from dw_fact_table
where
id_butaca = 175044501
How can I remove the empty values and put the values in the same row?
id_butaca, max_fecha_compra, max_fecha_devo
175044501 2023-01-09 12:11:04.0 2023-01-09 12:09:55
2
Answers
Maybe something like this?
This will help you to merge two rows in one row.