-
在SQL语言基础中,涉及子查询时使用分组函数的场景
资源介绍
在子查询中使用分组函数
*
ENAME JOB SAL
---------- --------- ---------
SMITH CLERK 800
SQL> SELECT ename, job, sal
2 FROM emp
3 WHERE sal =
4 (SELECT MIN(sal)
5 FROM emp);
800
*
SELECT ename, job, sal FROM emp WHERE sal =
(SELECT MIN(sal) FROM emp);
Using Group Functions in a Subquery
You can display data from a main query by using a group function in a subquery to return a single row. The subquery is in parentheses and is placed after the comparison operator.
The example on the slide displays the employee name, job title, and salary of all employees whose salary is equal to the minimum salary. The MIN group function returns a single value (800) to the outer query.