Selecting max value from calculated column in mysql
I have a mysql select statement which goes like this开发者_C百科:
Select a,b,calculated_column from table t1;
I come up with the calculated_column based on some logic and calculated_column is NOT a column in table t1.
How do I make this select statement return only the max value of the calculated_column?
Try using a derived table:
SELECT MAX(calculated_column) AS MyMax
FROM
(
SELECT a,b,calculated_column
FROM table t1;
) t2
精彩评论