Hi All,

Again following up:

When I create a table, SQLite enumerates the rows in the rowid column.

When I create a view, is there any way to enumerate the output rows?

Another method would I've developed/discovered is to create a temporary table, fill it with the data from the view, then use the automatically created rowid column as the enumeration. This works, but is not ideal since the creation of a temporary table can't be included in a view itself.

So, to solve the previous example:

create view "Planets Sorted" as select Name from Planets order by Name;

we could do something like:

begin immediate
;
create temporary table Enumerated
as select * from "Planets Sorted"
;
select rowid as Sequence, * from Enumerated
;
commit
;

which gives the desired:

1 Earth
2 Jupiter
3 Mars
4 Mercury
5 Venus

This "create temporary table" method is the same syntax for any view, unlike the "deconstruct the order into comparisons" method that I posted before which requires adding custom comparison operators. But the temporary table can't be included in a view, whereas the deconstruct method can. So neither is ideal but the best I've got so far.

Any better alternatives welcome :-)

Tom


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to