My friend asked this question to me –
You are given a table with just one field which is an integer. Can
you get the highest value in the field without using the MAX function
?
I think we can change the sign of each column and find the minimum using MIN function. Is that correct?
Why you would ignore using the function supported on any database is anyone’s guess, especially if you’d use the MIN function, but…
GREATEST
…some database vendors support the GREATEST function:
GREATESTreturns the highest value, of all the columns specified. Those that supportGREATESTinclude:TOP/LIMIT
TOPis SQL Server (2000+) only:LIMITis only supported by MySQL, PostgreSQL and SQLiteROW_NUMBER
ROW_NUMBER is supported by PostgreSQL 8.4+, Oracle 9i+, SQL Server 2005+: