James K. Lowden wrote: > Simon <turne...@gmail.com> wrote: >> select datetime(bucket*plen,'unixepoch','-5 hour') dt, >> (select price from last_trades where tid=opentr) open, > > Unless I misread it, that subquery returns the price for every row in > last_trades whose tid is equal to opentr. If that's not a scalar > result, you should get an error, and maybe not the one you want.
SQLite silently ignores surplus results: > select (select 1 union all select 2); 1 and synthesizes a NULL for empty results: > select (select 1 where 0); The only thing checked is the number of columns: > select (select 1, 2); Error: only a single result allowed for a SELECT that is part of an expression > I think the actual error is > >> from ( >> select cast(date/periodlen as int) bucket,periodlen,* >> from last_trades t, (select 5*60 periodlen) t2 >> where isprimary='Y' ) GROUP by bucket > > I bet the SQL parser swallows GROUP as the name of your virtual table. SQLite handles this correctly: > select * from (select 42) group by 1; 42 and doesn't allow unquoted keywords as alias names: > select * from (select 42) as group; Error: near "group": syntax error The problem appears to be using the aggregate result in a subquery in the SELECT clause: > select m from (select min(x) as m from (select 1 as x)); 1 > select (select m) from (select min(x) as m from (select 1 as x)); Error: misuse of aggregate: min() As far as I can see, this should be legal. Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users