Reputation: 2103
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?
Upvotes: 0
Views: 87
Reputation: 780798
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
Upvotes: 4