oracle数据库的sql语句练习1

oracle数据库的sql语句练习//1. 查询员工表所有数据select*fromemployees//2. 打印公司里所有的manager_idselectmanager_idfromemployees//3. 查询所员工的email全名,公司email统一以”@zpark.cn”结尾selectemail||‘@zpark.cn’asemailf…

大家好,又见面了,我是你们的朋友全栈君。


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://javaforall.net/126820.html原文链接:https://javaforall.net

(0)
上一篇 2022年4月8日 下午6:20
下一篇 2022年4月8日 下午6:20


相关推荐

  • 驼峰命名法等命名规范

    驼峰命名法等命名规范人们交流靠各种语言 每行都有每行的所谓的 行话 程序员也不例外 众所周知 程序员都是用代码进行交流的 那么除了在代码中的注释之外 程序员如何读懂别人的程序呢 当然 程序员之间也有所谓的 潜规则 大家都把代码中的变量 函数和类等等用目前常用的匈牙利命名 驼峰式 帕斯卡命名法来进行命名 一 匈牙利命名法匈牙利命名法通过在变量名前面加上相应的小写字母的符号标识作为前缀 标识出变量的作用域 类型

    2026年3月18日
    1
  • 点云语义分割_语义分割研究内容

    点云语义分割_语义分割研究内容SGPN[CVPR2018]:点云的实例分割与物体检测。(SGPN:SimilarityGroupProposalNetworkfor3DPointCloudInstanceSegmentation。RSNet[CVPR2018]:点云的语义分割。(RecurrentSliceNetworksfor3DSegmentationonPointCloud…

    2022年8月23日
    10
  • 使用pip install mysqlclient命令安装mysqlclient失败?

    使用pip install mysqlclient命令安装mysqlclient失败?写在前面我们使用 Django flask 等来操作 MySQL 实际上底层还是通过 Python 来操作的 因此我们想要用 Django 来操作 MySQL 首先还是需要安装一个驱动程序 在 Python3 中 驱动程序有多种选择 比如有 pymysql 以及 mysqlclient 等 常见的 Mysql 驱动介绍 MySQL python 也就是 MySQLdb 是对 C 语言操作 MySQL 数据库的一个简单封装 遵

    2026年3月18日
    1
  • mybatis看这一篇就够了,简单全面一发入魂

    mybatis看这一篇就够了,简单全面一发入魂文章目录Mybatis概述快速入门原生开发示例基于Mapper代理的示例基于注解的示例应用场景主键返回批量查询动态SQL缓存关联查询延迟加载逆向工程PageHelper分页插件MybatisPlusMybatis概述mybatis是什么?有什么特点?它是一款半自动的ORM持久层框架,具有较高的SQL灵活性,支持高级映射(一对一,一对多),动态SQL,延迟加载和缓存等特性,但它的数据库无关性较低什么是ORM?ObjectRelationMapping,对象关系映射。对象指的是Java

    2022年7月14日
    22
  • Sql语句里的递归查询(转)

    Sql语句里的递归查询(转)

    2021年8月28日
    86
  • windows启动、重启nginx

    windows启动、重启nginxwindows中启动、重启nginx命令1.找到nginx的安装目录,在目录上cmd进入黑窗口;2.启动startnginx3.配置文件nginx.conf修改重装载命令nginx-sreload

    2025年7月9日
    6

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号