I am confused whether at-sign variables could ever work in MonetDB. Is it standard SQL or only mySQL? (See eg this answer here on SO.) MonetDB claims to support SQL:2003 (full feature list here , hard for me to parse), but this is what they say on variables.
The following line fails in MonetDB complaining about the unexpected symbol :
. But is there a way to get this work? I see no way to combine a SET
(after DECLARE
) with SELECT
.
SELECT @firstq := QUANTILE(share26_2007,0.25) FROM sys.share26_2007;
(Afterwards, the following is the intended use case:)
SELECT peorglopnr, CASE WHEN share26_2007 < @firstq THEN 1
As already pointed out in the comments, @
variables are not standard SQL.
Using DECLARE
and SET
would work::
DECLARE firstq double;
SET firstq = ( SELECT quantile(share26_2007, 0.25) FROM share26_2007 );
SELECT peorglopnr, CASE WHEN share26_2007 < firstq THEN 1 .....
Notes:
share26_2007
which has a column share26_2007
. I followed this assumption. firstq
as double
. Your example does not specify the type of column share26_2007
. Change the variable type accordingly. quantile
seems not to work correctly in MonetDB (see https://www.monetdb.org/bugzilla/show_bug.cgi?id=4076 ), but this is unrelated to your question. The syntax above works (you may want to verify that by replacing quantile
with sys.quantile
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.