+ -
当前位置:首页 → 问答吧 → mysql函数怎么嵌套

mysql函数怎么嵌套

时间:2011-12-07

来源:互联网

例如 sum(max(score)) 我想这样用 但是报错 请问怎么可以实现

作者: strivehard   发布时间: 2011-12-07

select sum(x) from (select max(col) as x from t) a;

作者: ACMAIN_CHM   发布时间: 2011-12-07

引用 1 楼 acmain_chm 的回复:

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;

如果俩个select他就不认识user.id了

作者: strivehard   发布时间: 2011-12-07

引用 2 楼 strivehard 的回复:

引用 1 楼 acmain_chm 的回复:

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;
……


把其它条件继续放在子查询里边呗:
select sum(x) from (select max(col) as x from t, user where t.userid = user.id) a;

作者: nicenight   发布时间: 2011-12-07

热门下载

更多