I am joining three tables and I am trying to show the latest date but the dates that are being returned are not the latest.
SELECT c.id, c.companyname,c.displayname, c.address1, c.address2,
c.town, c.postcode,cd.contactname cd.contactphone, cd.contactemail,
MAX(q.coldate)
FROM companies c, query q, custd cd
WHERE c.id = q.id AND q.id = cd.compid
AND year(q.coldate) >= 2016
GROUP BY q.companyname;
How can I fix this please?