9951 explained code solutions for 126 technologies


clickhouseUsing subqueries in WITH queries


WITH (SELECT max(id) FROM tbl) as mxid SELECT * from tbl1 WHERE id > mxidctrl + c
WITH

allows defining user variables

SELECT max(id) FROM tbl

subquery which returns single value

as mxid

name of the variable to assign subquery result to

id > mxid

using variable in a query