Subquery: if another query is included in a subquery, The subquery format is SELECT {DISTINCT} * | column name 1 alias 1, column name 2 alias 2, FROM table name 1 alias 1, table name 2 alias 2, (SELECT {DISTINCT} * | column name 1 alias 1, column name 2 alias 2, FROM table name 1 alias 1, table name 2 alias 2, {WHERE condition (s)} {group by grouping condition {HAVING grouping condition }}{ order by sorting field ASC | DESC, sorting field ACS | DESC ,}{ WHERE condition (s) (www.2cto.com SELECT {DISTINCT} * | column name 1 alias 1, column name 2 alias 2, FROM table name 1 alias 1, table name 2 alias 2, {WHERE condition (s)} {group by grouping condition {HAVING grouping condition }}{ order by sorting word Segment ASC | DESC, sorting field ACS | DESC ,}{ group by grouping condition {HAVING grouping condition }}{ order by sorting field ASC | DESC, sorting field ACS | DESC ,} all subqueries must write code in. Subqueries can be divided into the following types in operations: Single-Column subqueries: The returned structure is a column of content, with the highest probability of occurrence of a single-row subquery: multiple returns, it may be a complete multi-row subquery of records: Multiple records are returned. If two employees with the lowest salary exist in a department at this time, the program will produce an error. IN a subquery, the operator www.2cto.com inanyall in is used to define a query range. SELECT * FROM empWHERE sal IN (select min (sal) FROM emp group by deptno); ANY operation: = ANY: similar to the IN operator, SELECT * FROM empWHERE sal = ANY (select min (sal) FROM emp group by deptno);> ANY: smaller than the smallest value, SELECT * FROM empWHERE sal> ANY (select min (sal) FROM emp group by deptno); <ANY: smaller than the maximum value: SELECT * FROM empWHERE sal <ANY (select min (sal) FROM emp group by deptno); ALL operation:> ALL: SELECT * FRO greater than the maximum value M empWHERE sal> ALL (select min (sal) FROM emp group by deptno); www.2cto.com <ALL is smaller than the smallest value SELECT * FROM empWHERE sal <ALL (select min (sal) FROM emp group by deptno); For subqueries, you can also perform multi-column subqueries. A subquery returns multiple query columns at the same time. SELECT * FROM empWHERE (sal, NVL (comm,-1) IN (SELECT sal, NVL (comm,-1) FROM emp WHERE deptno = 20 );