Here is the best answer in terms of maintenance and performance.
WITH query1 AS (
SELECT ...
),
query2 AS (
SELECT ...
)
SELECT *
FROM query1
UNION ALL
SELECT *
FROM query2
WHERE NOT EXISTS (
SELECT NULL
FROM query1
);
please mark as a answer
Thanks for explaining...
ReplyDelete