Oracle-05
来源:互联网 发布:手机能编程么 编辑:程序博客网 时间:2024/06/15 14:25
1./*查询在纽约工作并且工资比'SCOTT'高的职员的名字、职业、工资。*/
我写的
SQL> select e.ename,e.job,e.sal from emp e,dept d where e.deptno=d.deptno and d.loc='NEW YORK' and e.sal >(select sal from emp where ename='SCOTT');
答案:
select * from emp
wheresal>
(select sal from emp where
ename ='SCOTT'
)
and
deptno=
(select deptno from dept where
loc='NEW YORK'
)
结果都是一样的
2.*1查询在第30号部门工作的所有受雇时间早于他的老板的职员的名字和受雇日期及其老板的名字及受雇日期。*/
SQL> select e.ename,e.hiredate,m.ename,m.hiredate from emp e,emp m where e.mgr=m.empno and e.hiredate<m.hiredate and e.deptno=30;
需要注意的是日期越大越是后面的,日期大的是后面来的
3.查询公司中所有职员所赚工资及所处的工资级别。*/
sal and s.hisal;
4.*补充要求查处每个员工姓名,工资,部门名称,工资在公司的等级,及其领导的姓名工资,工资等级*/
SQL> select e.ename,e.sal,d.dname,s.grade,m.ename,m.sal,g.grade from emp e,emp m
,dept d,salgrade s,salgrade g where e.mgr=m.empno and e.deptno=d.deptno and (e.s
al between s.losal and s.hisal) and (m.sal between g.losal and g.hisal);
答案:
select e.ename 员工姓名,m.ename 领导姓名,e.sal 员工工资, d.dname 员工部门,
decode(s.grade ,1,'第五等级',2,'第四等级',3,'第三等级',4,'第二等级',5,'第一等级') 员工等级,
m.sal 领导工资, ms.grade 领导等级 ,md.dname 老板部门
from emp e, emp m,salgrade s,dept d,salgrade ms,dept md
where e.sal between s.losal and s.hisal
and e.mgr=m.empno
and d.deptno=e.deptno
and m.sal between ms.losal and ms.hisal
and m.deptno=md.deptno
学习了decode函数,意思是拿选出来的值与所列值比较如果相同则用紧随其后的字符串代替其在列中值
- Oracle-05
- oracle入门05
- oracle入门05
- Oracle Procedure示例05
- ORACLE数据库学习05
- 05 Oracle process
- ORACLE数据库总结05
- ORACLE 05 基本查询
- oracle笔记05
- Oracle???
- oracle
- oracle
- oracle
- oracle
- oracle...
- oracle
- oracle
- ORACLE
- 数据库-关系代数
- Node.js Module – exports 和module.exports之间的联系与区别
- RAC后台进程说明
- epoll使用示例
- 嵌入式linux2.6平台搭建——bootloader、Linux内核、根文件系统、开源工程
- Oracle-05
- 漫谈TCP/IP
- 利用OLEDB更新EXCEL报错
- CCIE K2+考点分析:MLS QOS MQC的配置实例
- VisionMobile:虚拟助手(VA)- Siri背后的前沿UI技术(二)
- 树形控件--zTree 很好很强大
- 基础总结篇之六:ContentProvider之读写联系人 (liuhe688)
- java的System.getProperty()方法可以获取的值
- CCNP-BGP/MPLS VPN配置实验