4

Possible Duplicate:
SQL Server equivalent to Oracle LEAST?
Function in SQL Server 2008 similar to GREATEST in mysql?

i am trying to find a SQL Server equivalent of oracle's "GREATEST" function.

something that would return the largest (in this case timestamp) from a list of values given

example: greatest(timestamp1, temestamp2, timestamp3) would return the most current date.

is there something like this in SQL Server i can use?

Thanks!

Community
  • 1
  • 1
Madam Zu Zu
  • 6,437
  • 19
  • 83
  • 129
  • There isn't a direct equivalent. The linked question covers the same ground except for the `LEAST` function. – Yuck Aug 13 '12 at 13:50
  • look at these two SO questions: http://stackoverflow.com/questions/124417/is-there-a-max-function-in-sql-server-that-takes-two-values-like-math-max-in-ne http://stackoverflow.com/questions/71022/sql-max-of-multiple-columns – Willem D'Haeseleer Aug 13 '12 at 13:51
  • thank you! i will take a look at the links now – Madam Zu Zu Aug 13 '12 at 13:52
  • Lots of great information here: http://dba.stackexchange.com/questions/21542/what-is-the-most-efficient-way-to-get-the-minimum-of-multiple-columns-on-sql-ser – Aaron Bertrand Aug 13 '12 at 13:55
  • @helmus - thanks! the udf in one of your links did it! – Madam Zu Zu Aug 13 '12 at 14:09

0 Answers0