Oracle经典查询练手第四篇

--1、 查询emp表中的所有信息select * from emp;--2、 显示emp表的雇员名称和工资。select ename,sal from emp;--3、 查询emp表中部门编号为20的并且sal(工资)大于3000的所有员工信息select * from emp where deptno=20 and sal >3000;--4、 查询emp表中部门编号为20的
摘要由CSDN通过智能技术生成
--1、	查询emp表中的所有信息
select * from emp;

--2、	显示emp表的雇员名称和工资。
select ename,sal from emp;

--3、	查询emp表中部门编号为20的并且sal(工资)大于3000的所有员工信息
select * from emp where deptno=20 and sal >3000;

--4、	查询emp表中部门编号为20的或者sal(工资)大于3000的所有员工信息
select * from emp where deptno=20 or sal >3000;

--5、	使用between and 查询工资在2000和4000之间的员工(用and 重新实现)
select * from emp where sal between 2000 and 4000;

--6、	使用in 查询 部门编号10,20的所有员工
select * from emp where deptno in (10,20);

--7、	使用like查询所有名字中包括 W的员工信息
select * from emp where ename like '%W%';

--8、	使用like查询所有员工名字中第二子字母为W的员工信息
select * from emp where ename like '_W%';

--9、	查询所有员工信息并按照部门编号和工资进行排序
select * from emp order by deptno ,sal;

--10、	显示雇员工资上浮20%的结果。
select ename,sal*1.2 from emp;

--11、	显示EMP表的雇员名称以及工资和津贴的和。
select ename,sal+(
  case
  when comm is null then 0
  else comm
  end ) from emp;

select ename,sal+nvl(comm,0) from emp;

--12、	在查询中使用列别名。特殊的别名如别名中有空格
select sal "the sal" from emp ;

--13、	显示DEPT表的内容,使用别名将表头转换成中文显示。
select deptno as 部门编号 , dname  as 部门名称,loc as  所在地址 from dept;

--14、	显示DEPT表的内容,按以下的形式:部门ACCOUNTING所在的城市为NEW YORK     
select '部门 '|| dname|| ' 所在的城市 ' ||loc from dept;

--15、	使用DISTINCT消除重复行显示。显示emp表中的的职位
select distinct job from emp;

--16、	查询雇员姓名和工资,并按工资从小到大排序。
select  ename ,sal from emp order by sal asc;

--17、	查询雇员姓名和雇佣日期,并按雇佣日期排序,后雇佣的先显示。
select ename ,hiredate from emp order by hiredate desc;

--18、	查询雇员信息,
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值