Subqueries

SELECT inside SELECT — solve complex problems step by step using subqueries. ## Lesson objectives In this lesson, we will learn subqueries in SQL. In the previous lessons, we wrote queries directly on tables. We learned , , , , , and . But in real work, we sometimes need to use the result of one SQL query inside another SQL query. For example: find employees who earn more than the average salary find the employee with the highest salary find customers who have no orders find products whose total sales are above the average select data from one table based on results from another table calculate a value first and then use it in the main query For these cases, we use a .