This query
SELECT PA.refPatient_id
,MAX(PA.datee) AS datee
,PR.temporary,PA.statue
FROM PatientClinicActs AS PA
,PatientStatueReasons AS PR
WHERE PA.refClinic_id = 25
AND PA.refreason_id = PR.reason_id
GROUP BY PA.refPatient_id,PA.statue,PR.temporary
returns these results:
refPatient_id datee temporary statue
----------- ----------------------- ------ -----
14706 2008-12-01 11:01:00 1 0
14707 2009-05-18 16:21:00 1 0
14708 2009-07-15 09:46:00 1 0
14708 2009-07-29 16:12:00 1 0
14716 2009-11-09 12:29:00 0 0
14716 2009-09-01 11:15:00 1 0
14716 2009-09-29 16:44:00 1 1
But i want to have these results:
refPatient_id datee temporary statue
----------- ----------------------- ------ -----
14706 2008-12-01 11:01:00 1 0
14707 2009-05-18 16:21:00 1 0
14708 2009-07-29 16:12:00 1 0
14716 2009-11-09 12:29:00 0 0
What is the difference ? => I have newest row for every refPatient_id in these results. What should i run to get these results?