oracle之基本的过滤和排序数据之课后练习
生活随笔
收集整理的這篇文章主要介紹了
oracle之基本的过滤和排序数据之课后练习
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
7. WHERE 子句緊隨 FROM 子句8. 查詢 last_name 為 'King' 的員工信息錯誤1: King 沒有加上 單引號select first_name, last_name
from employees
where last_name = King錯誤2: 在單引號中的值區(qū)分大小寫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). 使用 ANDselect *from employeeswhere salary >= 5000 and salary <= 100002). 使用 BETWEEN .. AND .., 注意: 包含邊界!!select *from employeeswhere salary between 5000 and 1000011. 查詢工資等于 6000, 7000, 8000, 9000, 10000 的員工信息1). 使用 ORselect *from employeeswhere salary = 6000 or salary = 7000 or salary = 8000 or salary = 9000 or salary = 100002). 使用 INselect *from employeeswhere salary in (6000, 7000, 8000, 9000, 10000)12. 查詢 LAST_NAME 中有 'o' 字符的所有員工信息.select *from employeeswhere last_name like '%o%'13. 查詢 LAST_NAME 中第二個字符是 'o' 的所有員工信息.select *from employeeswhere last_name like '_o%'14. 查詢 LAST_NAME 中含有 '_' 字符的所有員工信息1). 準備工作:update employeesset last_name = 'Jones_Tom'where employee_id = 1952). 使用 escape 說明轉(zhuǎn)義字符.select *from employeeswhere last_name like '%\_%' escape '\'15. 查詢 COMMISSION_PCT 字段為空的所有員工信息select last_name, commission_pctfrom employeeswhere commission_pct is null16. 查詢 COMMISSION_PCT 字段不為空的所有員工信息select last_name, commission_pctfrom employeeswhere commission_pct is not null17. ORDER BY:1). 若查詢中有表達式運算, 一般使用別名排序2). 按多個列排序: 先按第一列排序, 若第一列中有相同的, 再按第二列排序. 格式: ORDER BY 一級排序列 ASC/DESC,二級排序列 ASC/DESC;
1. 查詢工資大于12000的員工姓名和工資
a) select last_name,salary
b) from employees
c) where salary > 12000
2. 查詢員工號為176的員工的姓名和部門號
a) select last_name,department_id
b) from employees
c) where employee_id = 176
3. 選擇工資不在5000到12000的員工的姓名和工資
a) select last_name,salary
b) from employees
c) --where salary < 5000 or salary > 12000
d) where salary not between 5000 and 12000
4. 選擇雇用時間在1998-02-01到1998-05-01之間的員工姓名,job_id和雇用時間
a) select last_name,job_id,hire_date
b) from employees
c) --where hire_date between '1-2月-1998' and '1-5月-1998'
d) where to_char(hire_date,'yyyy-mm-dd') between '1998-02-01' and '1998-05-01'
5. 選擇在20或50號部門工作的員工姓名和部門號
a) select last_name,department_id
b) from employees
c) where department_id = 20 or department_id = 50
d) --where department_id in (20,50)
6. 選擇在1994年雇用的員工的姓名和雇用時間
a) select last_name,hire_date
b) from employees
c) --where hire_date like '%94'
d) where to_char(hire_date,'yyyy') = '1994'
7. 選擇公司中沒有管理者的員工姓名及job_id
a) select last_name,job_id
b) from employees
c) where manager_id is null
8. 選擇公司中有獎金的員工姓名,工資和獎金級別
a) select last_name,salary,commission_pct
b) from employees
c) where commission_pct is not null
9. 選擇員工姓名的第三個字母是a的員工姓名
a) select last_name
b) from employees
c) where last_name like '__a%'
10. 選擇姓名中有字母a和e的員工姓名
a) select last_name
b) from employees
c) where last_name like '%a%e%' or last_name like '%e%a%'
?
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的oracle之基本的过滤和排序数据之课后练习的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(1969)vue之电商管理系统
- 下一篇: RIA技术