Skip to content

Instantly share code, notes, and snippets.

@dalmat36
Last active August 29, 2015 13:57
Show Gist options
  • Save dalmat36/9574903 to your computer and use it in GitHub Desktop.
Save dalmat36/9574903 to your computer and use it in GitHub Desktop.
Multiple Gists
/*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