Me gustaría juntar el resto de algunas consultas usando UNION. Pero quiero ejecutar solo algunas de las consultas... en el ejemplo a continuación, la parte ('Daily','Yearly') se completará automáticamente.
algo a lo largo de las líneas de:
(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)En este ejemplo, el resultado de la segunda consulta no debería estar presente en la salida.
en una nota al margen: ya tengo las 3 consultas de trabajo, lo que me falta es cómo ejecutarlas dinámicamente y juntarlas en una sola salida.
Trate de poner estas condiciones en las secciones apropiadas de "Dónde". El motor debe omitir las consultas si no se cumplen las condiciones literales.
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')