Thursday, November 21, 2019

MIN/MAX vs LEAST/GREATEST

Today, I learned about the SQL functions LEAST() and GREATEST().

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!