2

I would like to put toghether the reslt of some queries by using UNION. But I want to execute only some of the queries... in the sample below the part ('Daily','Yearly') will be filled in automatically.

something along the lines of:

(if 'Daily' in ('Daily','Yearly') then
my first query goes here...
end if)
UNION ALL
(if 'Monthly' in ('Daily','Yearly') then
my second query goes here...
end if)
UNION ALL
(if 'Yearly' in ('Daily','Yearly') then
my third query goes here...
end if)

In this sample, the result of the second query should not be present in the output.

on a side note: I do already have the 3 working queries, what i am missing is how to execute them dynamically and put them toghether to a single output.

1 Answer 1

4

Try to put these conditions in the appropriate "Where" sections. Engine have to skip queries if the literal conditions are not met.

my first query goes here...
Where 'Daily' in ('Daily','Yearly')
UNION ALL
my second query goes here...
Where 'Monthly' in ('Daily','Yearly')
UNION ALL
my third query goes here...
Where 'Yearly' in ('Daily','Yearly')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.