oracle学习88-oracle之基本的过滤和排序数据

oracle学习88-oracle之基本的过滤和排序数据

--查询对应的列 大于5000
select employee_id,last_name,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 hire_date='7-6月-1994'
where to_char(hire_date,'yyyy-mm-dd')='1994-06-07'

运行结果

比较运算

--员工的工资大于4000并且小鱼7000
select employee_id,last_name,salary from employees
where salary between 4000 and 7000

运行结果

--员工的部门 70 80 90
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%'

--员工名字中含有下划线
select last_name,department_id,salary from employees
where last_name like '%\_%' escape '\'

运行结果

空值

--查询空值
select last_name,department_id,salary,commission_pct from employees
where commission_pct is null

运行结果

--查询部门80 并且工资小鱼5000
select last_name,department_id,salary,commission_pct from employees
where department_id='80' and salary<=8000

运行结果

优先级

--排序 从高到低
select last_name,department_id,salary,commission_pct from employees
where department_id='80'order by salary desc

运行结果

--排序 从高到低 双排序
select last_name,department_id,salary,commission_pct from employees
--where department_id='80'
order by salary desc,last_name desc

运行结果