I have the situation where I need to get the record of the latest date and then the max SEQ
number. Example:
CLIENT_ID STATUS DATE SEQ
10 1 2019-01-03 1
10 2 2019-01-03 2
10 4 2019-01-02 3
10 4 2019-01-01 2
Expected result
CLIENT_ID STATUS DATE SEQ
10 2 2019-01-03 2
I have tried the following code however I am having problem to filter the SEQ
variable a to get the max value
SELECT client_ID,status,maxdate
FROM sitcli
INNER JOIN (SELECT MAX(date) maxdate
FROM sitcli GROUP BY 1) a
ON sitcli.client_id=a.client_id AND a.maxdate=sitcli.date;
Appreciate any help