I've read the documentation[1] a few times and I don't understand why I get:

    Error: no such column: z

with a query like the one below:

    CREATE TABLE t1(x INTEGER, y INTEGER);
    INSERT INTO t1(x, y) VALUES(2, 1), (3, 2), (6, 4);
    CREATE TABLE t2(z INTEGER);
    INSERT INTO t2(z) VALUES(4);
    SELECT (SELECT y FROM t1 ORDER BY abs(x - z) LIMIT 1) FROM t2;

I expect to get a result like:

    SELECT (SELECT y FROM t1 ORDER BY abs(x - 4) LIMIT 1) FROM t2;
    2

The actual query I'm trying to write is more complicated and involves date
functions; I hope this explains enough. I'm using 3.15.2:

    sqlite> .version
    SQLite 3.15.2 2016-11-28 19:13:37 bbd85d235f7037c6a033a9690534391ffeacecc8

I appreciate any help you can offer. Thanks in advance!

Keith Maxwell

[1] https://www.sqlite.org/lang_select.html#order-by
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to