一定要group by no,job,不然语法错误
select no avg(sal) from tb group by no也可以

解决方案 »

  1.   

    select ename, job,sal from emp
    where deptno, in
    (select deptno form dept where dname in ('account', 'sales'))
    可是这段代码为什么没有group by命令的情况下不会报错呢
      

  2.   

    注意:如果在一个查询中使用了分组函数,那么任何不在分组函数中的列或表达式必须在GROUP BY 子句中。select no,job avg(sal)使用了分组函数avg(),而
    select ename, job,sal from emp
    where deptno, in
    (select deptno form dept where dname in ('account', 'sales'))
    中没有任何分组函数!!
      

  3.   

    记住,用group by 分组时,必须包括除函数列之外的所有列名。