Skip to content

Instantly share code, notes, and snippets.

@spaghettidba
Created March 6, 2018 09:55
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 spaghettidba/a363c0984a9c911742235f1b121251d0 to your computer and use it in GitHub Desktop.
Save spaghettidba/a363c0984a9c911742235f1b121251d0 to your computer and use it in GitHub Desktop.
MAX of multiple columns
SELECT MAX(n)
FROM (
SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS d, 5 AS e, 6 AS f, 7 AS g, 8 AS h, 9 AS i, 10 AS j
) AS sourceData
UNPIVOT (n FOR r IN (a,b,c,d,e,f,g,h,i,j)) AS u;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment