On Apr 13, 2012, at 3:14 PM, Steinar Midtskogen wrote: > Puneet Kishor <punk.k...@gmail.com> writes: > >> If you want the results in separate columns, you can do something like >> >> SELECT Min(a) minimum, 'none' maximum FROM t UNION ALL SELECT 'none' >> minimum, Max(a) minimum FROM t; > > Then it does a full scan again. > > But Igor's suggestion "SELECT (SELECT min(unix_time) FROM table), > (SELECT max(unix_time) FROM table)" works fine, and means less code. >
Yes, Igor's suggestion is definitely better, but where is the full table scan? sqlite> EXPLAIN QUERY PLAN SELECT Min(a) FROM t UNION ALL SELECT Max(a) FROM t; selectid|order|from|detail 1|0|0|SEARCH TABLE t USING INTEGER PRIMARY KEY (~1 rows) 2|0|0|SEARCH TABLE t USING INTEGER PRIMARY KEY (~1 rows) 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (UNION ALL) Am I missing something? -- Puneet Kishor _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users