mysql函数怎么嵌套
例如 sum(max(score)) 我想这样用 但是报错 请问怎么可以实现
select sum(x) from (select max(col) as x from t) a;
探讨
引用:
select sum(x) from (select max(col) as x from t) a;
对不起 忘了说了 只能是一个select 因为我还有其他的条件 如
select sum(x) from (select max(col) as x from t where t.userid = user.id) a;
……
分组错误,sum是分一组,max是分好几组(按你的意思),不一致,应该为select sum(m) from
(select max(..) m from ..);
sum(max(score))
select sum(ms)
from (
select username,max(score) as ms
from tb
group by username
)T