Redshift variable hack
04 Jun 2019Being a data warehouse, Redshift from AWS doesn’t provide the same level of programming platform that you may have had the luxury of using.
The concept of variables in Redshift is non existant however with this clever hack you can fake your way into some variable based information.
The same trick can be achieved using CREATE TEMP TABLE
also. The temporary table version will allow you to use your variables outside of the context of that one query. As above, the variables are bound to the CTE feeding the query.