当前位置: 首页>編程日記>正文

oracle数据库的sql语句练习1

oracle数据库的sql语句练习1

oracle数据库的sql语句练习1

//1. 查询员工表所有数据
select * from employees

//2. 打印公司里所有的manager_id
select manager_id from employees

//3. 查询所员工的email全名,公司email 统一以 "@zpark.cn" 结尾
select email || ‘@ zpark.cn’
as email
from employees;

//4. 按照入职日期由新到旧排列员工信息
select hire_date
from employees
order by hire_date desc;

//5. 查询80号部门的所有员工
select department_id from employees where department_id = 80

//6. 查询50号部门每人增长1000元工资之后的人员姓名及工资.

//普通方法1
select first_name,salary,salary+1000,department_id
from employees
where department_id=50;

//分组方法2
select first_name,salary,salary+1000,department_id
from employees
where department_id=50
group by first_name,salary,salary+1000,department_id;

//7. 查询80号部门工资大于7000的员工的全名与工资.

select first_name,salary,department_id
from employees
where salary>7000 and department_id=80;

//8. 查询80号部门工资大于8000并且佣金高于0.3的员工姓名,工资以及提成
select first_name,salary,salary * 0.3,department_id
from employees
where salary>8000 and commission_pct>0.30 and department_id=80;

//9. 查询职位(job_id)为’AD_PRES’的员工的工资

//模糊条件查询

select *from employees

select first_name,job_id,salary
from employees
where job_id like ‘AD_PRES’;

//10. 查询佣金(commission_pct)为0或为NULL的员工信息

//is null ,is not null,or

select *
from employees
where commission_pct is null or commission_pct=0 ;

//11. 查询入职日期在1997-5-1到1997-12-31之间的所有员工信息

//区间比较:between

select *
from employees
where to_char(hire_date,‘yyyy-MM-dd’)
between ‘1997-05-01’ and ‘1997-12-31’ ;

//12. 显示姓名中没有’L’字的员工的详细信息或含有’SM’字的员工信息

//模糊条件查询

select *
from employees
where first_name not like ‘%l%’ or first_name like ‘%sm%’;

//13. 查询电话号码以5开头的所有员工信息.

//模糊查询

select *
from employees
where phone_number like ‘5%’;

//14. 查询80号部门中last_name以n结尾的所有员工信息

select *
from employees
where department_id=80 and last_name like ‘%n’;

//15. 查询所有last_name 由四个以上字母组成的员工信息

select *
from employees
where last_name like ‘%____%’;

// 单行函数练习

//1. 把hire_date列看做是员工的生日,查询本月过生日的员工(考察知识点:单行函数)

select *
from employees
where to_char(hire_date,‘mm’) = 04;

//2. 查询2002年下半年入职的员工(考察知识点:单行函数)
select *
from employees
where to_char(hire_date,‘yyyy-MM’) > ‘2002-06’;

//3. 打印自己出生了多少天
select sysdate-to_date(‘1996-09-30’,‘yyyy-MM-dd’) from dual;

//4. 打印入职时间超过30年的员工信息

select *
from employees
where to_char(sysdate,‘yyyy’)-to_char(hire_date,‘yyyy’)>=30;

//组函数练习

//1. 显示各种职位的最低工资(组函数)

select job_id,min(salary)
from employees
group by job_id;

//2. 求1997年各个月入职的的员工个数(考察知识点:组函数)

select to_char(hire_date,‘MM’),count(*)
from employees
where to_char(hire_date,‘yyyy’)=‘1997’
group by to_char(hire_date,‘MM’);

//3. 查询每个部门,每种职位的最高工资(考察知识点:分组)
select department_id,job_id,max(salary)
from employees
group by department_id,job_id;

//4. 查询各部门的总工资
select department_id ,sum(salary)
from employees
group by department_id

//5. 查询50号部门,60号部门,70号部门的平均工资
select department_id,avg(salary)
from employees
where department_id=50 or department_id=60 or department_id=70
group by department_id;

//6. 查询各部门的最高工资,最低工资.
select department_id,max(salary),min(salary)
from employees
group by department_id

//7. 查询各岗位的员工总数.

select job_id,count(*)
from employees
group by job_id

//8. 查询各部门中各个岗位的平均工资.

select department_id,job_id,avg(salary)
from employees
group by department_id,job_id


https://www.fengoutiyan.com/post/13472.html

相关文章:

  • 鏡像模式如何設置在哪,圖片鏡像操作
  • 什么軟件可以把圖片鏡像翻轉,C#圖片處理 解決左右鏡像相反(旋轉圖片)
  • 手機照片鏡像翻轉,C#圖像鏡像
  • 視頻鏡像翻轉軟件,python圖片鏡像翻轉_python中鏡像實現方法
  • 什么軟件可以把圖片鏡像翻轉,利用PS實現圖片的鏡像處理
  • 照片鏡像翻轉app,java實現圖片鏡像翻轉
  • 什么軟件可以把圖片鏡像翻轉,python圖片鏡像翻轉_python圖像處理之鏡像實現方法
  • matlab下載,matlab如何鏡像處理圖片,matlab實現圖像鏡像
  • 圖片鏡像翻轉,MATLAB:鏡像圖片
  • 鏡像翻轉圖片的軟件,圖像處理:實現圖片鏡像(基于python)
  • canvas可畫,JavaScript - canvas - 鏡像圖片
  • 圖片鏡像翻轉,UGUI優化:使用鏡像圖片
  • Codeforces,CodeForces 1253C
  • MySQL下載安裝,Mysql ERROR: 1253 解決方法
  • 勝利大逃亡英雄逃亡方案,HDU - 1253 勝利大逃亡 BFS
  • 大一c語言期末考試試題及答案匯總,電大計算機C語言1253,1253《C語言程序設計》電大期末精彩試題及其問題詳解
  • lu求解線性方程組,P1253 [yLOI2018] 扶蘇的問題 (線段樹)
  • c語言程序設計基礎題庫,1253號C語言程序設計試題,2016年1月試卷號1253C語言程序設計A.pdf
  • 信奧賽一本通官網,【信奧賽一本通】1253:抓住那頭牛(詳細代碼)
  • c語言程序設計1253,1253c語言程序設計a(2010年1月)
  • 勝利大逃亡英雄逃亡方案,BFS——1253 勝利大逃亡
  • 直流電壓測量模塊,IM1253B交直流電能計量模塊(艾銳達光電)
  • c語言程序設計第三版課后答案,【渝粵題庫】國家開放大學2021春1253C語言程序設計答案
  • 18轉換為二進制,1253. 將數字轉換為16進制
  • light-emitting diode,LightOJ-1253 Misere Nim
  • masterroyale魔改版,1253 Dungeon Master
  • codeformer官網中文版,codeforces.1253 B
  • c語言程序設計考研真題及答案,2020C語言程序設計1253,1253計算機科學與技術專業C語言程序設計A科目2020年09月國家開 放大學(中央廣播電視大學)
  • c語言程序設計基礎題庫,1253本科2016c語言程序設計試題,1253電大《C語言程序設計A》試題和答案200901
  • 肇事逃逸車輛無法聯系到車主怎么辦,1253尋找肇事司機