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
oracle数据库的sql语句练习1相关推荐
- Oracle数据库中SQL语句用法(一)
Copyright © 2019 @Linyer. All Rights Reserved 下接Oracle数据库中SQL语句用法(二)[点击以查看] 目录 第1章:编写基本的SQL SELECT语句 ...
- Asp.Net访问Oracle 数据库 执行SQL语句和调用存储过程
Web服务器的配置: 1.安装Oracle 客户端 参考 Oracle 9i & PLSQL 全简体中文版数据库安装过程(图解),在选择安装的时候仅安装客户端即可 2.为安装客户端的服务器配置 ...
- oracle数据库分区SQL语句
表分区:将一个表格的数据,按照不同的特征,分开进行存放和管理 一.表分区的创建方法 create table 表名( 列名 数据类型 ) partition by 分区类型(分区的列名) ( 分区的规 ...
- Python 技术篇-操作oracle数据库执行SQL语句报错,提示ORA-00911: 无效字符解决方法
cursor.execute("select name from v$datafile;") 执行 sql 语句提示无效字符. 原因就是我加入了 ; 号. 改成 cursor.ex ...
- oracle数据库拼接sql语句字符串问题
近日遇到一个问题,在使用存储过程拼接动态语句时,传输参数一直提示无效标识符,研究发现拼接sql语句的时候,作为字符串参数的变量要加' ',具体代码如下: declarevc_sql varchar2( ...
- 关于Oracle数据库的SQL语句使用时的一些技巧。
在Oracle中,别名不能用在where语句中 比如 SELECT t*,to_char(d.date 'yyyy') AS year FROM tabTest t,tabDate d where ...
- Oracle数据库常用SQL语句查询
查询第一条记录 where语句后面跟上 and rownum=1 2.日期所相差分钟数 ceil((LOGOUT_TIME - LOGIN_TIME) * 24 * 60) 3.group by分组 ...
- Oracle数据库初学者:sql语句创建数据库表空间,建表语句
1. 表空间的创建 表空间的创建,格式: create tablespace 表空间名 datefile '路径名/表空间名.dbf' size 60M(初始空间大小为:60M) autoextend ...
- Oracle 数据库利用sql语句判断某个表是否是临时表实例演示,达梦数据库查询出所有临时表
-- 创建临时表 create global temporary table tem_1 (pk_tem char); -- 创建常规表 create table not_tem_1 (pk_not_ ...
- Oracle 数据库利用sql语句杀掉用户session进程,“ORA-01940: 无法删除当前连接的用户“问题解决办法
错误报告 - ORA-01940: 无法删除当前连接的用户 01940. 00000 - "cannot drop a user that is currently connected&qu ...
最新文章
- ansible笔记(11):初识ansible playbook(二)
- OpenCV ORB角点检测
- 用LIBSVM做回归和预测
- python中mat函数_Python中flatten( )函数及函数用法详解
- filter和map的区别
- java引用微信支付的p12证书文件
- 结构专业规范大全_建筑业最新规范大全!拿着手机看规范、查标准,超级方便...
- 【BLE】CC2640芯片简介
- 光分配网(ODN)一级分光和二级分光的区别及应用场景
- tf.executing_eagerly()
- 讯飞配音使用记录:Excel VBA 编程处理多段短文字配音切分及 Hedit、GoldWave 后期处理、编程合成 WAV 文件
- 谨以此辞职信祭奠我的第一份工作
- Http 400错误重现实验及解决办法
- 美国电子计算机大学排名,美国大学电子计算机专业排名院校有哪些?
- [工具使用]SqlMap
- SSCNet环境搭建
- AG6202-MAQ|安格AG6202|HDMI转VGA方案|AG安格设计方案
- 利用FileReader和FileWriter完成一个文件拷贝功能
- 微信知识付费小程序梦想贩卖机v2-1.0.67源码下载+无限裂变
- Erroe:ESS-07311 FaultCode=Couldn't create SOAP message due to exception: XML reader error;