Paul Sanderson wrote:
> I Have a number of queries to which I want to supply an incrementing column,
> some of these queries involve without rowid tables.
>
> Is there a way of doing this with a SQL query?
First, define a sort order, and ensure that it does not have duplicates.
Then use a correlated subquery to count how many rows would come before
the current one in that order:
SELECT (SELECT count(*)
FROM MyTable AS T2
WHERE T2.name <= MyTable.Name
) AS row_number,
name,
age
FROM MyTable
ORDER BY name;
It would be a better idea to count returned rows in your program.
Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users