I need to transform my Postgresql query to Redshift and I working with the following data, here is an excerpt:
In my final output, I would like only to keep rows with the highest rank (in green). And I was using the following query, which works to get the output, but I have to transform it into Redshift because the visualization tool is only using Redshift and Redshift doesn't recognize DISTINCT ON.
select distinct on customer_id
id_created,
customer_id,
call_start,
status_prior,
status_after,
rank() over (partition by customer_id order by call_start) as rank
order by customer_id, rank desc;