Skip to content

Instantly share code, notes, and snippets.

@pigreco
Created November 8, 2017 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigreco/b8e87cfd0dba5525d2fdb514d2fc71fa to your computer and use it in GitHub Desktop.
Save pigreco/b8e87cfd0dba5525d2fdb514d2fc71fa to your computer and use it in GitHub Desktop.
numeri sequenziali per gruppi di valori
SELECT cod, (SELECT count(*) FROM mia_tabella b WHERE a.cod = b.cod AND a.ROWID >= b.ROWID) AS cod_seq2
FROM mia_tabella a
-- mia_tabella esempio -- thread https://goo.gl/3NjJtX
-- cod,cod_seq
-- 029.151,1
-- 122.756,1
-- 122.756,2
-- 122.756,3
-- 122.756,4
-- 704.001,1
-- 704.001,2
-- 599.864,1
-- 354.365,1
-- 354.365,2
-- 009.975,1
-- 747.301,1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment