-- using declarations
@set datex_start = cast('2120-01-01' as date) as date_start;
-- datex_start is the var name
-- casting the value in the declaration saves us the work later
-- the var can be given a default fieldname (e.g. "date_start")
-- run as a standalone command since the subsequent SELECT statement doesn't return values when it's all run together
select
${datex_start}
;
基于来自@nicoschl 的非常有用的帖子,这里有一些小的改进:
这将返回一个字段名为“date_start”的值“2120-01-01”。