Interview Question

What is subquery?

A subquery supplies a query result to another statement.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

A subquery is a query nested inside another SQL statement. • It can produce a scalar value, a row, or a table-like result depending on context. • It may appear in expressions, FROM, WHERE, or other supported clauses. • The database optimizer may transform its execution.

💡 SQL Example

SELECT name FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);

Result

Employees earning above the average

⚡ Quick Revision

A subquery supplies a query result to another statement.