How can I get a query to display sequential row number in a select statement?
I have a simple database similar to this:
$ sqlite3 db .dump
BEGIN TRANSACTION;
CREATE TABLE foo (field);
INSERT INTO "foo" VALUES('a');
INSERT INTO "foo" VALUES('b');
INSERT INTO "foo" VALUES('c');
COMMIT;
$ sqlite3 db 'select * from foo ; '
a
b
c
I would like to do the equivalent of this in SQL:
$ sqlite3 db 'select * from foo order by field desc ; ' | cat -n
1 c
2 b
3 a
I have looked into rowid but it keeps the actual row id from the table
and does not reorder the rowid based on the sort order.
Pointers to references appreciated.
Regards,
- Robert
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users