Re: [sqlite] correlated subquery in LIMIT/OFFSET?

2013-04-11 Thread James K. Lowden
On Thu, 11 Apr 2013 17:14:43 +0200 Clemens Ladisch wrote: > >> It should come (or be derived) from the current row in the outer > >> query. > > > > Sorry, but inner queries are performed first. > > Sorry, but *correlated* inner queries are performed once for each > record in the outer query. *L

Re: [sqlite] correlated subquery in LIMIT/OFFSET?

2013-04-11 Thread Clemens Ladisch
Simon Slavin wrote: > On 11 Apr 2013, at 2:38pm, Clemens Ladisch wrote: >>> sqlite> create table t(x); >>> sqlite> select (select 42 limit 1 offset (select t.x)) from t; >>> Error: no such column: t.x > >> It should come (or be derived) from the current row in the outer query. > > Sorry, but in

Re: [sqlite] correlated subquery in LIMIT/OFFSET?

2013-04-11 Thread Simon Slavin
On 11 Apr 2013, at 2:38pm, Clemens Ladisch wrote: >> sqlite> create table t(x); >> sqlite> select (select 42 limit 1 offset (select t.x)) from t; >> Error: no such column: t.x > It should come (or be derived) from the current row in the outer query. Sorry, but inner queries are performed fi

Re: [sqlite] correlated subquery in LIMIT/OFFSET?

2013-04-11 Thread Michael Black
rsday, April 11, 2013 8:39 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] correlated subquery in LIMIT/OFFSET? Michael Black wrote: > > However, it appears that SQLite does not allow correlated subqueries > > in the LIMIT/OFFSET clauses of a scalar subquery: > > > &g

Re: [sqlite] correlated subquery in LIMIT/OFFSET?

2013-04-11 Thread Clemens Ladisch
Michael Black wrote: > > 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 > > Instead

Re: [sqlite] correlated subquery in LIMIT/OFFSET?

2013-04-11 Thread Michael Black
rs-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 OF

[sqlite] correlated subquery in LIMIT/OFFSET?

2013-04-11 Thread Clemens Ladisch
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>