Creating Parameters
The way to adjust queries quickly
Creating a filters table within a query can be a huge timesaver to quickly adjust or reuse parameters.
For example:
Not only can this quickly be adjusted to take a new end_date, but the top three lines can then be copy pasted into other queries with the same WHERE clauses. This requires some query standardization, but can lend speed for initial investigations of a known dataset.
Note, this can work differently depending on the dialect of SQL used, so check your documentation. As well, this can make queries more susceptible to injection attacks if outward facing.
Nonetheless, this is fairly universal and very useful to be able to quickly run a query, then rerun with slightly different parameters.
Last updated