Instead of "select t.x" don't you really want "select x from t" ??

That seems to work at least syntactically.  I assume you just want the
offset to come from a single-row table?
Mike


-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Clemens Ladisch
Sent: Thursday, April 11, 2013 8:15 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] correlated subquery in LIMIT/OFFSET?

Hi,

for computing the median of a group, it would be useful to be able to
use a correlated subquery as the expression in a OFFSET clause.

However, it appears that SQLite does not allow correlated subqueries
in the LIMIT/OFFSET clauses of a scalar subquery:

  sqlite> create table t(x);
  sqlite> select (select 42 limit 1 offset (select t.x)) from t;
  Error: no such column: t.x

Is this behaviour by design?

The documentation says that the LIMIT clause of a scalar subquery is
ignored and gets replaced with 1, but this shouldn't disallow the syntax
above, and should not apply to the OFFSET value in any case.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to