Sure, give each derived table an alias. (and, in the future, put your sql query in a set of code tags and indent it for easy reading)
select x,y,x from ((
select x,y,z from table join othertable ...
) AS TABLE1 UNION ( -- THIS IS A TABLE ALIAS
select x,y,z from table join othertable ...
group by somefieldoranother
) AS TABLE2 -- THIS IS A TABLE ALIAS
) AS temp group by ....