I’m trying to write a query that derives the most recent contributors by combining ids and dates from two tables.
The query below almost works but the “group by” is not showing the most recent date. How do I modify this to show the last 10 contributors without showing the same users twice?
CREATE TEMPORARY TABLE recent
SELECT stories.volunteer_id volunteer_id,
stories.date_added date_added
FROM stories
WHERE volunteer_id >0
group by volunteer_id
UNION
SELECT
partner_documents.volunteer_id volunteer_id,
partner_documents.date_added date_added
FROM partner_documents
WHERE volunteer_id >0
group by volunteer_id;
SELECT volunteer_id, date_added FROM recent ORDER BY date_added DESC
Limit 10