SQLite Forum

UPDATE ROW_COUNT
Login
For completeness, here is the version that will work using COUNTs rather than the ROW_NUMBER window function:

```
WITH RC(rci,rcn) AS (
    SELECT t1.fnidx, COUNT(*)
      FROM tnTEST AS t1
      JOIN tnTEST AS t2 ON t2.fnidx <= t1.fnidx
     GROUP BY t1.fnidx
)
UPDATE tnTEST SET fnrownum = (SELECT rcn FROM RC WHERE rci=fnidx)
;

```
The base advantage here is that it will work on all SQL engines, including older SQLite versions (since it does not need WINDOW functions), BUT it will be significantly slower for any decently sized dataset.