Do you want rowid perhaps for a guaranteed one-to-one mapping to the row regardless of the query? Or are you looking for a repeatable one-up counter for the query results?
select rowid,id,name from people ORDER BY name; If you want a one-up counter automagically you can create another table from the query like this example too: sqlite> create table a(b); sqlite> insert into a values(1); sqlite> insert into a values(2); sqlite> insert into a values(3); sqlite> insert into a values(4); sqlite> insert into a values(5); sqlite> create table c as select * from a where (b % 2)==0; sqlite> select rowid,* from c; 1|2 2|4 Mike -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Paxdo Sent: Tuesday, June 04, 2013 4:50 AM To: General Discussion of SQLite Database Subject: [sqlite] Row_number? Hello, I have a problem and I do not find the solution with Sqlite. I need an equivalent to ROW_NUMBER. Here's the problem: SELECT id, name FROM people ORDER BY name On this, I would like to know the line number of the ID 34, how? example: SELECT id, name FROM people ORDER BY name Result: 12 Arthur 23 Bill 5 Chris 34 Ron 43 William The line number of the ID34 is 4. But how to know with sqlite? Thank you very much! Olivier _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users