I have a query which is a UNION of two Queries:
SELECT first_name, last_name, email
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.promoter = true
AND o.ticket = 'HOTEL'
UNION ALL
SELECT first_name, last_name, email
FROM users u
WHERE u.id IN (
'232drt-erty3-dff3',
'sswer3-ddf33-675t',
'we2311-23xxw-11vb'
)
I would like to know if is it possibile to define the two queries as variables and call them Q1 and Q2 So that my query becomes something like
SELECT *
FROM (
Q1 UNION ALL Q2
)