0

アットマーク変数が MonetDB で機能するかどうか、私は混乱しています。標準 SQL ですか、それとも mySQL のみですか? (たとえば、SOに関するこの回答を参照してください。)MonetDBはSQL:2003をサポートすると主張しています(完全な機能リストはこちら、解析するのは難しい)が、これは変数について彼らが言っていることです。

次の行は、MonetDB で失敗し、予期しないシンボルについて不平を言っています:。しかし、この仕事を得る方法はありますか?SET(after DECLARE) とを組み合わせる方法がわかりませんSELECT

SELECT @firstq := QUANTILE(share26_2007,0.25) FROM sys.share26_2007;

(その後、以下は意図されたユースケースです:)

SELECT peorglopnr, CASE WHEN share26_2007 < @firstq THEN 1
4

1 に答える 1

-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:

  • What I understand from your example is that you have a table share26_2007 which has a column share26_2007. I followed this assumption.
  • I declared the variable firstq as double. Your example does not specify the type of column share26_2007. Change the variable type accordingly.
  • When setting the value of a variable to the result of a SELECT that returns an atomic value, you do need parentheses around the SELECT.
  • 現時点quantileでは MonetDB で正しく動作していないようですが ( https://www.monetdb.org/bugzilla/show_bug.cgi?id=4076を参照)、これはあなたの質問とは関係ありません。上記の構文は機能します ( に置き換えて確認することをお勧めしますquantile) sys.quantile
于 2016-09-30T10:21:12.717 に答える