0

I have viewed many Q&A's regarding selecting MIN value from column names i.e find min and max but my problem is not solved.

SELECT MIN(column1  + (5 * 24 * 60 * 60) AS deadline1, column2 +(1 * 24 * 60 * 60) AS deadline2) AS deadline FROM table_name  

Showing error code Error Code : 1064

How can I select the minimum value from both values? any idea plz?

Community
  • 1
  • 1
Suleman Ahmad
  • 2,025
  • 4
  • 28
  • 43

1 Answers1

4

MySQL uses MIN only as an aggregate function. To select the minimum of several expressions, you have to use LEAST:

SELECT LEAST(column1  + (5 * 24 * 60 * 60), column2 +(1 * 24 * 60 * 60)) AS deadline FROM table_name 
Barmar
  • 741,623
  • 53
  • 500
  • 612