SQLite Forum

UPDATE ROW_COUNT
Login
You are asking about row-counting but the intended result you posted looks a lot more like row-numbering.
There is a way to do it using row-counting, but it is convoluted involving self-referencing joins.

Assuming it's a misprint and you meant row-numbering, this would do it:

```
WITH RC(rci,rcn) AS (
    SELECT fnidx, ROW_NUMBER() OVER (PARTITION BY 1 ORDER BY fnidx ASC)
      FROM tnTEST
)
UPDATE tnTEST SET fnrownum = (SELECT rcn FROM RC WHERE rci=fnidx)
;

```

Note: I typed this from my imagination, so not tested and might have some syntax fault that needs adjusting, but I'm pretty sure the idea is sound.