Question about making a union with two tables

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

Awesome thank you

SELECT volunteer_id 
     , MAX(date_added) AS last_added
  FROM stories
 WHERE volunteer_id > 0 
GROUP
    BY volunteer_id
UNION 
SELECT volunteer_id 
     , MAX(date_added)
  FROM partner_documents 
 WHERE volunteer_id > 0
GROUP
    BY volunteer_id
ORDER 
    BY last_added DESC LIMIT 10

you don’t really need the temporary table

Select the MAX of stories.date_added and partner_documents.date_added