Subquery in FROM clause
- Last Updated: May 12, 2026
- 1 minute read
- OpenAccess SDK
- Version 8.1
- Documentation
Subqueries can be used in the FROM clause in place of table references.
Examples
SELECT * from (SELECT * FROM emp where sal > 10000) new_emp, dept
WHERE new_emp.deptno = dept.deptno
SELECT * from (SELECT empno FROM emp)
Limitations of syntax in nested subquery
-
GROUP BY usage is not always support in nested subquery:
SELECT newemp.deptno, dept.dname FROM (SELECT deptno, COUNT(*) AS empcountFROM emp GROUP BY deptno) newemp, deptWHERE newemp.deptno = dept.deptno; -
SET functions in subquery are not always supported:
SELECT * FROM (SELECT deptno, count(*) AS empcountFROM emp GROUP BY deptno) newempWHERE empcount > 2;