EMP(empno,ename,job,mgr,hiredate,sal,comm.,deptno);
DEPT(deptno,dname,loc);
1、按照雇员编号升序显示所有雇员的信息;
select * from emp order by empno asc
2、查询没有奖金的所有雇员名称及其部门信息;
select e.ename,d.* from emp e,dept d where e.deptno=d.deptno and
nvl(comm,0) =0
3、查询姓名以M开头的所有雇员的姓名、生日及部门;
select e.ename,e.birthday,d.dname --假设生日字段为birthday
from emp e,dept d where e.deptno=d.deptno
and e.ename like 'M%'
4、查询1978年出生的所有雇员信息;--假设生日字段为birthday
select * from emp where birthday between to_date('1978','yyyy') and to_date('1979','yyyy')
5、查询所有部门的雇员人数;
select deptno,count(*)
from emp
group by deptno
6、查询雇员人数超过5个的部门名称。
select d.dname
from emp e,dept d
where e.deptno=d.deptno
group by d.dname
having count(*)>5
7、查询所有雇员的名称及其最终工资。
select ename,sal*(1+nvl(comm,0)) total_sal
from emp
8、查询没有雇员的部门名称
select d.dname
from dept d,emp e
where d.deptno(+)=e.deptno
and d.deptno is null
9、显示每个雇员的名称及拟调整后工资,调整工资原则:原工资高于2000的加100,原工资低于2000的加200;
select ename,sal+(case when sal>2000 then 100 when sal select to_date('1978','yyyy') from dual;
TO_DATE('1978','YYYY')
----------------------
1978-12-1
哦, 起始时间变成了1978-12-1, 看来1978-11-30的都不是78年生的了, 注意现在的时间是12月
最开始回答的答案只有在1月份使用的时候才能无意中得到正确的结果 |