Let's say I have a salary table with a 'paymonth' column (date of payment) 'code1' column (some human resources code) and 'code2' column (another human resources code).
Here is the content of the table:
paymonth        code1      code2    payment
-------------------------------------------
01/01/2021      11             3    1000
01/01/2021      11             1    750
01/02/2021      11             3    650
For every different couple of code1, code2, I would like to get the last rows entered. The problem here is that line 1 and line 2 have the same paymonth date.
So a query like this one:
select * from salary
order by paymonth
fetch first 2 row only;
would give:
01/01/2021      11             3    1000
01/02/2021      11             3    650
This is not what I want. I would like this (different codes):
01/01/2021      11             1    750
01/02/2021      11             3    650
Can you help?
 
     
    