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

解决方案 »

  1.   

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

  2.   


    对不起 忘了说了 只能是一个select  因为我还有其他的条件 如select sum(x) from (select max(col) as x from t where t.userid = user.id) a;如果俩个select他就不认识user.id了
      

  3.   


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

  4.   

    分组错误,sum是分一组,max是分好几组(按你的意思),不一致,应该为select sum(m) from
    (select max(..) m from ..);
      

  5.   

    sum(max(score))
    select sum(ms)
    from (
    select username,max(score) as ms
    from tb
    group by username
    )T