Skip to content
Advertisement

Redshift – Missing latest date when join two tables

I have two tables (Calling as A and B table);

Table – A data only includes the last 1 month data. Table – B data stores all data that you have.

I need to find the difference between these two tables dates, but when I left joined the two tables I have null dates:

I am going to use last_value over () function but I am still missing the first null value. How can I store each user previous last value (for user A 2019-11-25)

Advertisement

Answer

You can use a full join along with lag()/last_value() and then filter:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement