Simon Slavin <[email protected]> writes:
> Rows do not have an order. Without an ORDER BY clause SELECT can return rows
> in a random order if it wants. If you would like to define 'order' for me I
> can give you a SELECT which will find the first non-NULL value in a column,
> probably something like
>
> SELECT c FROM v WHERE c IS NOT NULL ORDER BY rowid LIMIT 1
Ok, so let's say the table v (with "a" as the primary key) is:
a|b|c|d|e|f
0| | |2| |9
1|1| |3| |8
2|1| |4|4|7
3| |5|5|4|6
4|1|6|6| |5
The the question becomes, is there a more convenient way to do:
SELECT * FROM (SELECT b FROM v WHERE b IS NOT NULL ORDER BY a LIMIT 1),
(SELECT c FROM v WHERE c IS NOT NULL ORDER BY a LIMIT 1),
(SELECT d FROM v WHERE d IS NOT NULL ORDER BY a LIMIT 1),
(SELECT e FROM v WHERE e IS NOT NULL ORDER BY a LIMIT 1),
(SELECT f FROM v WHERE f IS NOT NULL ORDER BY a LIMIT 1);
to get 1|5|2|4|9?
--
Steinar Midtskogen
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users