I'm looking for the Spark SQL equivalent of the T-SQL select @variable = AVG(something) FROM ... construct.
I would like to assign the scalar returned from select avg(year) from values ("John", 33), ("Karen", 20), ("Gladys", 25) as data(name, year) to a variable or widget, and use it the where condition of later queries.
The reference on widgets shows how to do this for dropdown lists, but not for simple text widgets. All the text widget examples assign constants, not dynamic values.
This is in a pure SQL Databricks notebook so I'd prefer a vanilla SQL solution if one exists.