Home


.Net, SQL and softball. Musings of a software developer with a softball problem

Wednesday, December 3, 2008

Max versus Greatest in Oracle

So I was trying to figure out the greatest of three dates in oracle. They were coming from 3 different columns across three different tables. So I figured I could do something like the following
SELECT MAX(A.date, B.date, C.date) FROM. . .etc

But apparently that doesn't work. The max function will not work across multiple columns. That's when I learned about the greatest function. Does the same thing as max, but lets you do it across multiple columns. The above query became
SELECT GREATEST(A.date, B.date, C.date) FROM . . .etc.

So, Max = one column, Greatest = multiple columns.

Labels:

posted by Tom Becker at

0 Comments:

Post a Comment

<< Home