I have the following result set generated from the query below
PATIENTID INVOICENO SVCDATE
14140 61531 2021-11-15 00:00:00.000
14140 64140 2021-12-09 00:00:00.000
14140 64478 2021-12-15 00:00:00.000
SELECT
WO.PATIENTID,
WO.INVOICENO,
WO.SVCDATE
FROM AR1ORDW WO
WHERE WO.BILLTYPE = 'P'
AND WO.SVCDATE <= '12/31/2021'
AND WO.PATIENTID = 14140
GROUP BY WO.PATIENTID, WO.SVCDATE, WO.INVOICENO
ORDER BY WO.PATIENTID, WO.SVCDATE;
Please notice the 2 records returned for the month of December (current month).
I need to select/show only one record for the current month and it has to be the last date (max date), as follows:
PATIENTID INVOICENO SVCDATE
14140 61531 2021-11-15 00:00:00.000
14140 64478 2021-12-15 00:00:00.000
I would like to modify the query I have to return only one record for the current month and it should be MAX(DATE)