Unlike MAX(), GREATEST() takes multiple arguments:
While both functions return the largest number in a group, MAX() can only have one argument (GREATEST() needs to have more than one):
MIN() vs. LEAST() works similarly:
More testing and research will have to be done to figure out why GREATEST() and LEAST() return a list of unordered values when you give it a column name:
I'll edit with my findings! Feel free to comment if you know why this happens!






Great post!
ReplyDeleteYou learn something new every day! Thanks for this awesome post.
ReplyDeleteThanks great post.
ReplyDeleteNice! Now I don't have to do the research.
ReplyDeleteYou're curious why "GREATEST() and LEAST() return a list of unordered values when you give it a column name". It's for the same reason that SQRT(seconds) would return a list of unordered second values; sql is applying that function to each value in that column. Greatest(x) = x, so it just spits back the raw data. It's unordered because all queries return unordered data unless you specifically ORDER it.
ReplyDeleteThanks for the clarity!
ReplyDelete