Skip to content
Advertisement

UNION Results from same SQL each with Different Parameter values

I have SQL that pulls data for a given timeframe. I want to run the SQL multiple times and merge/union the results together into one result set. Currently I copy the SQL and change the date ranges. As an example:

Since I need to repeat this for multiple years, I would like to make the year a parameter and execute the SQL repeatedly for each of the years and have all the runs merged together into one results set.

Advertisement

Answer

Why not do it as a single query? No need to UNION based on what you have shown.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement