ROW_NUMBER by Ciro Santilli 34 Updated Created
sqlite3 ':memory:'  'WITH t (i) AS (VALUES (-1), (-1), (-2)) SELECT *, row_number() over () FROM t'
Possible output:
-1|1
-1|2
-2|3
Gives them unique IDs.
With a partition by:
sqlite3 ':memory:'  'WITH t (i) AS (VALUES (-1), (-1), (-2)) SELECT *, row_number() over ( partition by i ) FROM t'
possible output:
-2|1
-1|1
-1|2