开发者

Selecting max value from calculated column in mysql

开发者 https://www.devze.com 2023-04-06 03:13 出处:网络
I have a mysql select statement which goes like this开发者_C百科: Select a,b,calculated_column from table t1;

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
0

精彩评论

暂无评论...
验证码 换一张
取 消