Учтите это:
-- temporary test table
CREATE TEMP TABLE tbl (id serial, nr int);
INSERT INTO tbl(nr) VALUES
(50),(79),(85),(74),(14)
,(79),(46),(85),(79),(45);
SELECT id, nr
,CASE WHEN grp > 0 THEN
row_number() OVER (PARTITION BY grp ORDER BY id)::text
ELSE '?' END AS rn
FROM (
SELECT id, nr
,sum(CASE WHEN nr = 79 THEN 1 ELSE 0 END) OVER (ORDER BY id) AS grp
FROM tbl) x
-- WHERE grp > 0 -- to exclude numbers before the first 79
Создает именно ваш результат.