Oracle SQL Lesson (8) - 使用集合操作符(Union,Intersect,Minus)
集合操作符
UNION/UNION ALL
INTERSECT
MINUS
Union All不排序,不去重,其余均升序且去重。
create table e1 as select * from emp where deptno in (10,20);
create table e2 as select * from emp where deptno in (20,30);
select * from e1 union select * from e2 order by 8
select * from e1 union all select * from e2 order by 8
select * from e1 intersect select * from e2 order by 1 desc
select * from e1 minus select * from e2 order by 1 desc
SELECT location_id, department_name "Department",
TO_CHAR(NULL) "Warehouse location"
FROM departments
UNION
SELECT location_id, TO_CHAR(NULL) "Department",
state_province
FROM locations;
SELECT employee_id, job_id,salary
FROM employees
UNION
SELECT employee_id, job_id,0
FROM job_history;
Oracle SQL Lesson (8) - 使用集合操作符(Union,Intersect,Minus)的更多相关文章
- 集合操作符 Union / Union All / Intersect / Minus
集合操作符 Union / UnionAll / Intersect / Minus -- 生成测试数据 create table dept_01 as select * from dept wher ...
- SQL Server中的集合运算: UNION, EXCEPT和INTERSECT
SQL Server中的集合运算包括UNION(合并),EXCEPT(差集)和INTERSECT(相交)三种. 集合运算的基本使用 1.UNION(合并两个查询结果集,隐式DINSTINCT,删除重复 ...
- Oracle SQL Lesson (6) - 使用Join进行联合查询
使用连接SQL 1999SELECT table1.column, table2.columnFROM table1[NATURAL JOIN table2] |[JOIN table2 USING ...
- Oracle SQL Lesson (9) - 操作数据(增删改)
使用INSERT语句INSERT INTO table [(column [, column...])]VALUES (value [, value...]); INSERT INTO departm ...
- Linq 集合操作符 Except,Intersect,Union
IList<string> s1 = new List<string>() { "One", "Two", "Three&qu ...
- Oracle SQL Lesson (2) - 限制和排序数据
重建scott用户@?/rdbms/admin/utlsampl.sql@--执行?--$ORACLE_HOME 字符区分大小写:SELECT last_name, job_id, departmen ...
- Oracle SQL Lesson (1) - 使用SQL Select语句获取数据
第一节课: 启动数据库并且使用特定用户连接:su - oracle; 启动sqlplus并且使用sys连接:conn / as sysdba; 启动数据库:startup; 解锁用户:alter us ...
- Oracle SQL Lesson (3) - 使用单行函数自定义输出
大小写转换函数LOWER('SQL Course') = sql courseUPPER('SQL Course') = SQL COURSEINITCAP('SQL Course') = Sql C ...
- Oracle SQL Lesson (4) - 使用转换函数和条件表达式
隐式转换select * from emp where empno='7788'字符(char,varchar2)转换为数字(number)或日期(date)数字或日期转换为字符 显式转换字符转换为数 ...
随机推荐
- Android架构分析之使用自定义硬件抽象层(HAL)模块
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz Android版本:2.3.7_r1 Linux内核版本:android-goldfish-2.6.29 在上一篇博 ...
- Delphi控件的停靠功能
Delphi自带的许多控件都有停靠功能,而且操作非常简单,大可不必选用第三方控件. 基本上,要进行Dock操作至少需要两个组件,一个人被附着的Dock Site组件,另一个人附在Dock ...
- Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Fai ...
- A Game of Thrones(18) - Catelyn
“We will make King’s Landing within the hour.” Catelyn turned away from the rail and forced herself ...
- Python基础 - 迭代
前言 在pythone中经常可以看到iterable这样的描述. 直译为迭代. 这是在C中没有的概念. iterable(可迭代) 支持每次返回自己所包含的一个成员的对象就是可迭代对象. iterab ...
- oracle 12c 中asm元数据是否有所变化
详见原文博客链接地址: oracle 12c 中asm元数据是否有所变化
- Android自己定义组件系列【2】——Scroller类
在上一篇中介绍了View类的scrollTo和scrollBy两个方法,对这两个方法不太了解的朋友能够先看<自己定义View及ViewGroup> scrollTo和scrollBy尽管实 ...
- WPF案例(-)模拟Windows7 Win+Tab切换
原文:WPF案例(-)模拟Windows7 Win+Tab切换 一个使用Wpf模拟Windows7 Win+Tab页面切换的小程序,使用快捷键Ctrl+Down或Ctrl+Up在示例程序各个页面元素之 ...
- A Game of Thrones(8) - Bran
The hunt left at dawn. The king wanted wild boar at the feast tonight. Prince Joffrey rode with his ...
- MySQL中CASE的使用
语法说明: 方式一: CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE ...