From 0a7aab1500a76c3bbd4cd056024eb208b4cfba8c Mon Sep 17 00:00:00 2001 From: Nick Woolmer <29717167+nwoolmer@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:03:28 +0000 Subject: [PATCH] add functions example --- documentation/reference/sql/declare.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/documentation/reference/sql/declare.md b/documentation/reference/sql/declare.md index c8f97e2a..8ba680f9 100644 --- a/documentation/reference/sql/declare.md +++ b/documentation/reference/sql/declare.md @@ -74,6 +74,23 @@ SELECT @x + @y |--------| | 7 | +### Variables as functions + +A variable need not be just a constant, it could be a function call, +and variables with function values can be nested: + +```questdb-sql title="declaring function variable" demo +DECLARE + @today := today(), + @start := interval_start(@today), + @end := interval_end(@today) +SELECT @today = interval(@start, @end) +``` + +| column | +|--------| +| true | + ### Declarations in subqueries