Finding uniform set of Rows returned by rank in Postgresql

15 Views Asked by At

I have a table in Postgresql

for which I performed analytical function and grouped as lastest records based on column_3

table 1:

![enter image description here

now as per the resulset org:2 have latest date(29-07-2023) so I should return all records of org:2 of rank 1,2,3

later ,in case if new value is added for column_3 for org:1 with date greater than lastest date of org:2(29-07-2023) then all records with ranks 1,2,3 based on org:1 should be returned

Query used:

    select column_1,column_2,column_3,column_4 ,dense_rank() OVER (PARTITION BY (column_3) ORDER BY column_4 desc) rn
from table_1;
0

There are 0 best solutions below