Last Updated: February 25, 2016
·
628
· milesmatthias

sqlite to print indexes of results

If you ever need to print the index of a row in your sqlite result set, here's what we've used:

SELECT (SELECT COUNT(0) FROM table1 S1 WHERE S1.id <= S.id) AS number, id FROM table1 S

and you'll get something like:

-------------
| number | id |
-------------
|  1     | A8U4-...
|  2     | AI84-...
|  3     | A9A4-...
|  4     | A044-...