Definitely after the FROM
, and most likely after the WHERE
line you could add:
FLATTEN choice(!endDate, date, endDate) as myEndDate
This would assign your value to myEndDate
which could be used elsewhere in your query(both later on, and in the column definitions.