I have this table that I want to return the firstname and fathername of all the records with the latest data ,should be dynamic whenever a new latest date is inserted to return that record. I've tried this
SELECT rh.firstname, rh.fathername, rh.bloodonation_date
FROM personprofile rh,
(SELECT MAX(bloodonationdate) AS maxdate, firstname
FROM report_history
GROUP BY firstname) maxresults
WHERE rh.firstname= maxresults.firstname
AND rh.bloodonation_date= maxresults.bloodonation_date;
So if I have this table
firstname, fathername,bloodonation_date
--------------------------
Ahmed issa 2018-12-24
Noora issa 2018-12-21
Joseph John 2018-12-24
Ash Scott 2018-12-24
Isacf jaack 2018-12-24
Ashley Make 2018-12-24
James Ma 2018-12-20
cd cd 2018-12-24
cde cde 2018-12-24
Marc Mac 2018-12-16
Noora Ahmed 2018-12-15
Rabeew fbdb 2018-11-15
How do I get it to return
firstname, fathername,bloodonation_date
--------------------------
Ahmed issa 2018-12-24
Joseph John 2018-12-24
Ash Scott 2018-12-24
Isacf jaack 2018-12-24
Ashley Make 2018-12-24
cd cd 2018-12-24