emp(eno,ename,salary,dno)员工号,员工姓名,工资,部门号
dept(dno,dname) 部门号,部门名称1)列出各个部门中工资不低于600的的员工的平均工资;
2)将工资低于600的员工工资提高10%;

解决方案 »

  1.   

    1,
    select dno,average(salary) from emp
    where salary >=600
    group by dno;2,
    update emp set salary=salary * 1.1 where salary < 600;
      

  2.   


    select dept.dname ,avg(salary) 
        from emp ,dept where emp.dno=dept.dno and emp.dno in (
            select dno from emp group by dno having salary >=600 );update emp set salary=salary * 1.1 
        where salary < 600 and emp.dno=(select dno from dept where dname ="销售部门";
    可能不是最优,期待高手
      

  3.   

    select dept.dname ,avg(salary) 
        from emp ,dept where emp.dno=dept.dno
           group by dept.dname  having salary >=600
      

  4.   

    我第一题这样写的,
    select dname,avgSalary from dept,(select dno, avg(salary) avgSalary from emp group by dno) e where e.dno = dept.dno我习惯这样写了 但是那个面试官说不对,
    是不是这种写法不被认可啊!
      

  5.   

    那个面试官说子查询写在from里的他没见过 当然我上面写的那个语句,子查询里落下一个条件 salary>=600
      

  6.   

    select dno avg(salary)
    from emp,dept
    where emp.dno= dept.dno and salary>600
    group by dept.dno;
      

  7.   

    select dname,avgSalary from dept,(select dno, avg(salary) avgSalary from emp group by dno) e where e.dno = dept.dno