一道SQL数据的简答题,请大家帮忙解决。

2025-01-04 02:01:38
推荐回答(1个)
回答1:

  1. select deptno as 部门号,min(sal) as 最低工资,max(sal) as 最高工资 from emp group by deptno

  2. select dname as 部门,ename as 员工,min(sal) as 最低工资,max(sal) as 最高工资 from emp,dept where emp.deptno=dept.deptno and emp.job='CLERK'  group by deptno

  3. select ename as 员工,deptno as 部门号 from emp where deptno in (select deptno
    from emp where emp.ename='buddy')

  4. select ename as 员工姓名,mgr as 管理者姓名 from emp where mgr<>''

  5. select deptno as 部门号,dname as 部门名,ename as 员工名,job as 工作 from dept,emp where dept.deptno=emp.deptno and emp.job='CLERK'



    第4题的where条件另一回答是where emp<>null   ,首先请问楼主emp表中有emp字段吗,其次就算有emp字段,也和null搭不上关系,应该是判断是否为空串,就算是和null搭得上关系,那么字段名和null之间是应该用什么连接的,<>null明显是语法错误,应该是emp is not null才对!明明是mgr字段嘛,我写的应该是对的呀,为什么采纳错误的答案?