For Oracle set query, the Orderby clause can only appear in the last statement. The column name or alias accepted by the first select statement
For Oracle set query, the Order by clause can only appear in the last statement. The column name or alias accepted by the first select statement
Homepage → Database Technology
Background:
Read News
Oracle collection Query
[Date: 2012-03-14] Source: Linux Author: java958199586 [Font:]
Union
Select * from emp where deptno = 10 union select * from emp where deptno = 20;
Select * from emp where deptno = 10 union all select * from emp where deptno = 20;
Select * from emp where ename like '% A %' or ename like '% M % ';
Select * from emp where ename like '% A %' union ename like '% M %'; // remove all parts
Select * from emp where ename like '% A %' union all ename like '% M %'; // do not remove
Intersection
Select * from emp where ename like '% A %' intersect ename like '% M %'; // common parts
Difference set
Belongs to first, not belongs to second
The Order by clause can only appear in the last statement. The column name or alias accepted by the first select statement
The column name of the query result must be the same as the column name of the first select statement.
Select * from (select * from emp where sal between 700 and 1300 union select * from emp where sal between 1200 and 1400) order by sal desc;
Select ename, sal from emp where sal between 700 adn 1300 union select ename, sal from emp where sal between 1200 and 1400 order by sal deces;
In the select statement, the parameter types and numbers must be consistent.
Brackets can be used to change the sequence of execution of the set.
The set operation uses the header of the first statement as the header.
0
Oracle index Scanning
Oracle Transaction Processing
Oracle Database tutorial
Image Information
View All comments in this article (0)
Comments
Latest Information
Popular this week
Introduction to Linux community-advertisement service-website map-help Info-contact us
The articles published on this site (LinuxIDC) do not mean that they agree with the statement or description. They only provide more information and do not constitute any suggestions.
Copyright©2006-2011 Linux community All rights reserved Zhejiang ICP backup No. 06018118