SET运算符
2024-09-07 15:04:18
-- SET操作符:
-- union 联合去重 两个表的字段个数和类型都得一样,起别名 应该在第一个表上操作,,排序按照第一列从小到大来排的
select employee_id, department_id
from employee01
union --union all
select employee_id, department_id
from employee02;
minus :取差集
-- 使两表字段个数和类型一致
select employee_id emp_id,dapartment_id,to_char(null)
from employees01
union
select to_number(null),department_id,department_name
from departments;
--查询10,50,20部门的job_id,department_id,且department_id 按10,50,20的顺序来排列
column a_dummy noprint;
select job_id,department_id,1 a_dummy
from employees
where department_id = 10
union
select job_id,department_id,2
from employees
where department_id = 50
union
select job_id,department_id,3
from employees
where department_id = 20
order by 3 asc;
JOB_ID DEPARTMENT_ID
---------- -------------
AD_ASST 10
SH_CLERK 50
ST_CLERK 50
ST_MAN 50
MK_MAN 20
MK_REP 20
--查询所有员工的last_name,department_id和department_name
select last_name,department_id,to_char(null)
from employees
union
select to_char(null), department_id,department_name
from departments;
最新文章
- 在Sublime TEXT3中添加brogrammer-theme主题配色方案
- 关于 IE6、 IE7兼容性总结(转)
- 推荐15款最好的 Twitter Bootstrap 开发工具
- sql脚本比较大,sqlserver 无法导入,就用cmd命令执行
- 转 DevExpress-ASPxPageControl 动态添加 TabPage 内容
- PHP学习笔记 - 进阶篇(5)
- ASP.NET页面生命周期总结(1)
- box-shadow属性
- git远程删除分支但本地git branch -a仍能看到解决
- 2. 2A03简介
- 探索SQL Server元数据(二)
- AXI4
- linux下通过curl访问web服务器
- VUE 项目刷新路由指向index.html
- EJB3 阶段总结+一个EJB3案例 (2)
- from setuptools import setup, find_packages ImportError: No module named set
- 20145237 Exp9 Web安全基础实践
- Java设计模式(9)——观察者模式
- 将 Python3 文件打包成 exe 文件
- Unity面试问题归总
热门文章
- python(If 判断)
- golang 容器的学习与实践
- 内存迟迟下不去,可能你就差一个GC.Collect
- SpringCloudStream学习(四)TTL(存活时间)Dead Letter Exchanges(死信交换机)
- spring学习笔记(一)@ConfigurationProperties注解
- 有感FOC算法学习与实现总结
- hdu5381 The sum of gcd]莫队算法
- [hdu5266]区间LCA
- pthon-安装新版PyQt5、PyQT5-tool后打不开并Designer.exe提示“This application failed to start because no Qt platform plugin could be initialized.Reinstalling the application the application may fix this program”
- python3.x 基础八:socket网络编程