SQL Variables in Databricks

<p>In the above code, I am making use of the&nbsp;<code>year_variable</code>&nbsp;variable. This was a slight workaround previously and followed an odd syntax with using&nbsp;<code>${var.variable_name}</code>. This workaround did not work in the Databricks SQL interface and only in the notebooks. So now that we have the official implementation, users can leverage variables regardless of execution environment. Please note that 14.1 is currently the latest runtime and may not be deployed in Databricks SQL current channel at this time.</p> <p>Fortunately, with the introduction of Databricks Runtime 14.1, variables are now fully supported! To gain a deeper understanding of this feature, please refer to our&nbsp;<a href="https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-aux-set-variable.html" rel="noopener ugc nofollow" target="_blank">documentation</a>. Here is a refactored version of the above query using the new syntax.</p> <p><a href="https://medium.com/@24chynoweth/sql-variables-in-databricks-12eca21a0fa1"><strong>Website</strong></a></p>