学习目标

** 查询中过滤行**
** 查询中对行进行排序**

select employee_id, last_name from employees;-- 查询工号大于200的
select employee_id, last_name
from employees
where employee_id > 200;-- 查询员工工资大于五千的员工姓名、工号和工资
select last_name, employee_id, salary
from employees
where salary > 5000;select last_name, hire_date
from employees
where hire_date = '7-6月-1994';select last_name, hire_date
from employees
where to_char(hire_date, 'yyyy-mm-dd') = '1994-06-07';-- 其他值比较
-- 操作符
-- between ... and ... 再两个值之间(包含边界)
select last_name, hire_date, salary
from employees
where salary >= 4000 and salary <= 7000;select last_name, hire_date, salary
from employees
where salary between 4000 and 300-- in
select last_name, department_id, salary
from employees
where department_id = 90;select last_name, department_id, salary
from employees
where department_id = 90 or department_id = 80 or department_id = 70;select last_name, department_id, salary
from employees
where department_id in(70, 80, 90);-- 模糊查询
-- 员工中字符含有a的
select last_name, department_id, salary
from employees
where last_name like '%a%';
-- 员工中字符末尾是含有a的
select last_name, department_id, salary
from employees
where last_name like '%a';
-- 员工中名字的第二位字符是a的 _是一个字符
select last_name, department_id, salary
from employees
where last_name like '_a%';
-- 员工名字中含有下划线的员工
-- 数据库中没有_的名字,所以修改了一个人的名字
update employees
set last_name = 'Wha_len'
where last_name = 'Whalen';
--查询 需要用到转义字符
select last_name, department_id, salary
from employees
where last_name like '%\_%' escape '\`'; --多加一个编译器有问题其实是不加的--空值 is null
-- 查询公司员工的奖金率是否为空值
select last_name, department_id, salary, commission_pcy
from employees
where commission_pcy is null;
-- 查询公司员工的奖金率是非空值
select last_name, department_id, salary, commission_pcy
from employees
where commission_pcy is not null;--排序 order by--查询80号部门的工资,让工资从高往低排
select last_name, department_id, salary
from employees
where department_id = 80
order by salary desc;
--查询80号部门的工资,让工资从低往高排
select last_name, department_id, salary
from employees
where department_id = 80
order by salary asc;--多层排序
-- 先按照工资来排序,在按照部门,最后按照姓名排序
select last_name, department_id, salary
from employees
order by salary asc, department_id asc, last_name asc;
--按照年工资来排序,可以使用别名
select last_name, department_id, salary, salary * 12 as "annual"
from employees
order by "annual" desc;-- practise
--1.查询工资大于12000 的员工
select last_name
from employees
where salary > 12000;
--2.查询工号为176的员工的姓名和部门号
select last_name, department_id
from employees
where department_id = 176;
--3.选择工资不在5000 到12000的员工的姓名和工资
select last_name, salary
from employees
where salary not between 5000 and 12000;
--4.选择雇佣时间在1998-02-01 到1998-05-01之间的员工姓名,job_id 和雇佣时间
select last_name, job_id, hire_date
from employees
where to_char(hire_date, "yyyy-mm-dd") between  = '1998-05-10' and '1998-05-10';
--5.选择在20或50号部门工作的员工姓名和部门号
select last_name, department_id
from employees
where department_id = 20 or department_id = 50;
-- where department_id in (20, 50);
6.选择在1994年雇佣的员工姓名和雇佣时间
select last_name, department_id
from employees
where tochar(hire_date, 'yyyy') = '1994';
--where tochar(hire_date, 'yyyy-mm-dd') like '1994%';
-- where hire_date like '%94';
7.选择公司中没有管理者的员工姓名及job_id
select last_name, job_id
from employees
where manager_id = null;
8.选择公司中有奖金的员工姓名,工资和奖金级别
select last_name, salary, commission_pcy
from employees
where commission_pcy is not null;
9.选择员工姓名的第三个字母是a的员工姓名
select last_name
from employees
where last_name like '__a%';
10.选择姓名中有a和e的员工姓名
select last_name
from employees
where between last_name like '%a%e%' or last_name like '%e%a%';

Oracle select 基础查询语句 day02相关推荐

  1. oracle 数据库怎么查询,Oracle 数据库基础查询

    1.1文件存储 对数据的存储需求一直存在.数据保存的方式,经历了手工管理.文件管理,数据库管理阶段. 文件存储方式保存数据的弊端: 1.缺乏对数据的整体管理,数据不便修改: 2.不利于数据分析和共享; ...

  2. groovy怎样从sql语句中截取表名_SQL常用的基础查询语句

    数据分析过程中,我们经常可以看到提数的SQL语句,了解SQL常用的基础查询语句,是检验提数逻辑是否正确的途径之一,并且也能更方便使用SMART BI数据分析工具.今天就让小编带大家走进SQL基础查询的 ...

  3. Oracle中分页查询语句

    Oracle分页查询语句使我们最常用的语句之一,下面就为您介绍的Oracle分页查询语句的用法,如果您对此方面感兴趣的话,不妨一看. Oracle分页查询语句基本上可以按照本文给出的格式来进行套用. ...

  4. Oracle数据库数据查询语句示例(包含大部分常用语句)

    Oracle数据库数据查询语句示例(包含大部分常用语句) 目标 本文用到的关系模式 语句示例 1.在创建的s,p,j和spj表中完成以下查询 (1)查询零件重量在10-20之间(包括10和20)的零件 ...

  5. MySQL入门 (二) : SELECT 基础查询

    1 查询资料前的基本概念 1.1 表格.纪录与栏位 表格是资料库储存资料的基本元件,它是由一些栏位组合而成的,储存在表格中的每一笔纪录就拥有这些栏位的资料. 以储存城市资料的表格「city」来说,设计 ...

  6. Oracle基本语法查询语句

    Oracle基本查询语法 本文含含: 基础/基本查询/排序/函数(单/多) 一.前言知识 1.oracle如何操作硬盘上的文件,最终都是以进程方式操作硬盘上的文件,最基本进程:读 写 ,还有其他客户端 ...

  7. oracle sql 分区查询语句_oracle11g 表分区后的查询语句如何知道是否进行了全表扫描...

    2019-05-10 回答 1. 对返回的行无任何限定条件,即没有where 子句 2. 未对数据表与任何索引主列相对应的行限定条件 例如:在city-state-zip列创建了三列复合索引,那么仅对 ...

  8. SQL(二)- 基础查询语句

    简单的查询语句(DQL) 下面我们正式来学习查询语句,下面所有查询用到的表均为前面提到的三张表: 员工表中的数据: 部门表中的数据: 薪资表中的数据: 基本查询语句的语法: select 字段 fro ...

  9. oracle带时间查询语句,请教oracle按时间分组查询语句的写法

    请教oracle按时间分组查询语句的写法 最近由于要做报表,在一张表中有一个字段为date类型,现在想要在一段时间内(比如一年)能够按照时间段分组查询记录总和,比如我要能够查询2007年到2009年间 ...

最新文章

  1. 网络推广费用浅析有关导致百度快照倒退的因素是什么?
  2. HTML5 处理响应式图片
  3. 重置忘记的mysql root密码
  4. 成功解决AttributeError: 'MapDataset' object has no attribute 'group_by_window'
  5. 利用状态图实现词法分析
  6. TikTok推出招聘服务、 沃尔玛收购虚ekit、开源圆桌、AI新创Poised|拟试穿公司ZeDecode the Week...
  7. 初始化环境配置:CentOS 7.4x64 系统安装及基础配置
  8. C语言程序的错误和警告
  9. linux工具-journalctl查询日志
  10. 在linux中at 调度出错,linux系统中的调度延迟任务:at 命令
  11. matlab实时处理数据,Matlab下实现的实时数据采集和处理
  12. 2021苏州大学计算机考研分数,2021苏州大学考研分数线已公布
  13. qq发送信息给对方一定经过服务器,QQ如何把你消息传递给好友的?(上篇)
  14. 根据点度分布情况,拟合线性公式
  15. 利用python爬取教务系统中成绩
  16. Trajectory generation for quadrotor while tracking a moving target in cluttered environment
  17. Linux学习路线及网络编程经典书籍
  18. DSP篇--C6701功能调试系列之 FLASH测试
  19. final关键字能修饰构造方法么?
  20. Invocation Target Exception调用目标异常可能是参数漏传

热门文章

  1. 机器学习中的数据预处理(sklearn preprocessing)
  2. 聊聊高并发(二十六)解析java.util.concurrent各个组件(八) 理解CountDownLatch闭锁
  3. Oracle jdk 历史版本官方下载地址及下载方法
  4. [Hadoop in China 2011] 华为 - NoSQL/NewSQL在传统IT产业的机遇和挑战
  5. 关于使用layui中的tree的一个坑
  6. .NET调用Oracle存储过程,使用数组类型的参数(如ArrayList)
  7. SpringCloud(第 017 篇)电影微服务接入Feign,添加 fallbackFactory 属性来触发请求进行容灾降级...
  8. Obejctive-C 中定义可变参函数
  9. HDU 2757 Ocean Currents
  10. 开始学java咯!~~~