What would your inner query look like?
💡 Model Answer
An inner query, also known as a subquery, is a SELECT statement nested inside another SQL statement. It is used to compute a value that is then used by the outer query. For example, to find employees who earn more than the average salary, you could write:
SELECT employee_id, name, salary
FROM employees
WHERE salary > (
SELECT AVG(salary)
FROM employees);
Here the inner query calculates the average salary, and the outer query filters employees based on that value. Inner queries can appear in SELECT, WHERE, HAVING, or FROM clauses, and they can return a single value or a set of rows. They are powerful for encapsulating complex logic and improving readability, but can impact performance if not indexed or if they return large result sets.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500