Some examples of SQL child query

zhaozj2021-02-16  53

1, single-line query Select Ename, DePTNO, Sal from Emp where deptno = (select deptno from dept where loc = 'new york');

2, multi-line query Select Ename, Job, Sal from Emp Where Deptno in (Select Deptno from DePt Where DName Like 'A%');

3, multi-column query Select Deptno, Ename, Job, Sal from Emp WHERE (Select Deptno, Max (SAL) from Emp Group by DEPTNO;

4, inner view, Query (1) SELECT ENAME, JOB, SAL, ROWNUM FROM (SELECT Ename, Job, Sal from Emp ORDER BY SAL); (2) Select Ename, Job, Sal, Rownum from (SELECT ENAME, JOB , Sal from Emp ORDER BY SAL, WHERE ROWNUM <= 5; 5, using subsets in the Having clause Select Deptno, Job, AVG (SAL) from Emp Group by DePTNO, Job Having Avg (SAL)> (Select Sal from " EMP where ename = 'martin');

转载请注明原文地址:https://www.9cbs.com/read-21591.html

New Post(0)