Is there a quick way of getting the maximum or minimum of some columns?
ie. say I want to select the maximum of two columns I can write it as:
Obviously the MAX function doesn't do this, ie
wont work. Using CASE WHEN is OK when there's only two columns but when there's more or a combination of maximum and minimum it becomes a real pain.
Sorry if this is real beginner stuff but any help would be appreciated!
ie. say I want to select the maximum of two columns I can write it as:
Code:
SELECT (CASE WHEN COL1>COL2 THEN COL1 ELSE COL2 END) AS RESULT
FROM etc...
Obviously the MAX function doesn't do this, ie
Code:
SELECT MAX(COL1,COL2) AS RESULT ...
wont work. Using CASE WHEN is OK when there's only two columns but when there's more or a combination of maximum and minimum it becomes a real pain.
Sorry if this is real beginner stuff but any help would be appreciated!