Skip to content

Instantly share code, notes, and snippets.

@dalmat36
Created March 11, 2014 15:29
Show Gist options
  • Save dalmat36/9488173 to your computer and use it in GitHub Desktop.
Save dalmat36/9488173 to your computer and use it in GitHub Desktop.
/*ROW_NUMBER() Window function assigns
unique incrementing integers to rows */
SELECT orderid, custid, val, ROW_NUMBER() OVER (PARTITION BY custid ORDER BY val) AS rownum
FROM Sales.OrderValues
ORDER BY custid, val;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment