oracle学习87-oracle之基本的过滤和排序数据之课后练习

7. WHERE 子句紧随 FROM 子句
 
8. 查询 last_name 为 'King' 的员工信息
 
错误1: King 没有加上 单引号
 
select first_name, last_name
from employees
where last_name = King
 
错误2: 在单引号中的值区分大小写
 
select first_name, last_name
from employees
where last_name = 'king'
 
正确
 
select first_name, last_name
from employees
where last_name = 'King'
 
9. 查询 1998-4-24 来公司的员工有哪些?
 
注意: 日期必须要放在单引号中, 且必须是指定的格式
 
select last_name, hire_date
from employees
where hire_date = '24-4月-1998'
 
10. 查询工资在 5000 -- 10000 之间的员工信息.
	
	1). 使用 AND
	select *
	from employees
	where salary >= 5000 and salary <= 10000
	
	2). 使用 BETWEEN .. AND ..,  注意: 包含边界!!
	select *
	from employees
	where salary between 5000 and 10000
 
11. 查询工资等于 6000, 7000, 8000, 9000, 10000 的员工信息
	
	1). 使用 OR
	select *
	from employees
	where salary = 6000 or salary = 7000 or salary = 8000 or salary = 9000 or salary = 10000
	
	2). 使用 IN
	select *
	from employees
	where salary in (6000, 7000, 8000, 9000, 10000)
 
12. 查询 LAST_NAME 中有 'o' 字符的所有员工信息.
	
	select *
	from employees
	where last_name like '%o%'
	
13. 查询 LAST_NAME 中第二个字符是 'o' 的所有员工信息.
 
	select *
	from employees
	where last_name like '_o%'
	
14. 查询 LAST_NAME 中含有 '_' 字符的所有员工信息
	
	1). 准备工作:
	update employees
	set last_name = 'Jones_Tom'
	where employee_id = 195
	
	2). 使用 escape 说明转义字符.
	select *
	from employees
	where last_name like '%\_%' escape '\'
 
15. 查询 COMMISSION_PCT 字段为空的所有员工信息
	select last_name, commission_pct
	from employees
	where commission_pct is null
	
16. 查询 COMMISSION_PCT 字段不为空的所有员工信息
	select last_name, commission_pct
	from employees
	where commission_pct is not null
 
17. ORDER BY:
	1). 若查询中有表达式运算, 一般使用别名排序
	2). 按多个列排序: 先按第一列排序, 若第一列中有相同的, 再按第二列排序. 
	格式:  ORDER BY 一级排序列 ASC/DESC,二级排序列 ASC/DESC;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值