列出所有员工的姓名、部门名称和工资。正确的SQL语句有________。
A: SELECT a.ename
,(SELECT b.dname FROM dept b) AS dname
,sal
FROM emp a
B: SELECT a.ename
,(SELECT b.dname FROM dept b WHERE b.deptno=a.deptno) AS dname
,sal
FROM emp a;
C: SELECT a.ename,b.dname,sal
FROM emp a,dept
D: SELECT a.ename,b.dname,sal
FROM emp a,dept b
WHERE a.deptno=b.deptno
A: SELECT a.ename
,(SELECT b.dname FROM dept b) AS dname
,sal
FROM emp a
B: SELECT a.ename
,(SELECT b.dname FROM dept b WHERE b.deptno=a.deptno) AS dname
,sal
FROM emp a;
C: SELECT a.ename,b.dname,sal
FROM emp a,dept
D: SELECT a.ename,b.dname,sal
FROM emp a,dept b
WHERE a.deptno=b.deptno
举一反三
- 列出所有部门的部门名称和部门员工人数。如果部门没有员工,人数显示为0。正确的查询语句有_________。 A: SELECT dname,COUNT(ename) AS ecount <br>FROM dept,emp <br>WHERE emp.deptno(+)=dept.deptno <br>GROUP BY dept.dname B: SELECT dname,(SELECT COUNT(*) AS ecount FROM emp WHERE emp.deptno=dept.deptno) <br>FROM dept C: SELECT dname,COUNT(ename) AS ecount <br>FROM dept LEFT JOIN emp ON emp.deptno=dept.deptno <br>GROUP BY dept.dname D: SELECT dname,COUNT(*) AS ecount <br>FROM dept LEFT JOIN emp ON emp.deptno=dept.deptno <br>GROUP BY dept.dname
- 以下语句不正确的是( ) A: select * from emp B: select ename,hiredate,sal from emp C: select * from emp order deptno D: select * from where deptno=1 and sal<300
- 以下语句不正确的是( ) A: select * from emp; B: select ename,hiredate,sal from emp; C: select * from emp order deptno; D: select * from where deptno=1
- 以下语句正确的是() A: select<br/>sal+1 from emp; B: select<br/>sal*10,sal*deptno from emp; C: 不能使用运算符号 D: select<br/>sal*10,deptno*10 from emp;
- 查询部门20的员工数量,每个月的工资总和及平均工资( ) A: SELECT sum(nvl(sal,0)),avg(nvl(sal,0)) from emp B: SELECT ename,sum(nvl(sal,0)),avg(nvl(sal,0)) from emp where deptno =20 group by deptno C: SELECT ename,count(empno),sum(nvl(sal,0)),avg(nvl(sal,0)) from emp where deptno =20 group by deptno D: SELECT count(empno),sum(nvl(sal,0)),avg(nvl(sal,0)) from emp where deptno =20 group by deptno