Expression or Constant in GroupBy Clause
(1) By Jinsheng Ba (bajinsheng) on 2022-05-17 14:09:20 [link] [source]
From the document, I noticed that both expression and constant integer are allowed in the Group By clause. I am a bit confused why the following expression is identified as constant integer, instead of expression.
CREATE TABLE t0(c0);
SELECT COUNT(*) FROM t0 ORDER BY (t0.c0 IN ());
-- Parse error: 1st ORDER BY term out of range - should be between 1 and 1
(2) By Richard Hipp (drh) on 2022-05-17 14:54:19 in reply to 1 [link] [source]
As an optimization, the SQLite parser treats expressions of the form
"<expr> IN ()
" and "<expr> NOT IN ()
" as alternative spellings for
constants 0 and 1, respectively. See the parse.y sources for
details.
(3) By Richard Hipp (drh) on 2022-05-17 15:11:23 in reply to 2 [link] [source]
Dan has now checked in a change that causes "<expr> IN ()
" to be an
alternative spelling for "false
" instead of "0
", which should fix
your problem, I think.
(4) By Jinsheng Ba (bajinsheng) on 2022-05-17 23:43:33 in reply to 3 [source]
Thanks!