I have 2 tables, using an inner join to query them.
SELECT COUNT(table2.id)
FROM table2
INNER JOIN table1 ON table2.relazioneid = table1.id
WHERE table1.date > ? AND table1.date < ?
It counts the ids of entries on reports between 2 dates. Table 1 holds info on the reports (date, groupid etc), table2 holds the entries on the reports.
I'd like to make a query almost exactly the same, except it only selects the ids from the report with the latest date, between those 2 dates.
Can anyone help? I can't quite get my head around MAX(date) type queries - all I get back is a count of every id and also the max date, rather than just those ids from the max date.
Thanks,