I want to fetch latest 3 different records from history table, below is my query.
select distinct(account_id)account_id,
creation_date,
category
from account_history
where account_id in('2345','3467','7896')
order by creation_date desc fetch first 3 rows only;
output: I am getting:
account_id creation_date category
2345 27-jan-22 p
3467 26-jan-22 p
3467 25-jan-22 p
required output:
account_id creation_date category
2345 27-jan-22 p
3467 26-jan-22 p
7896 24-jan-22 p