A query that is nested inside another query is called a subquery. It permits you to fetch data based on the outcomes of another query.
For instance, in the below-given query, the subquery will fetch the list of customers who ordered something within February 2023.
SELECT * FROM customers WHERE customer_id IS IN (ORDER_DATE > ‘2023-02-01’ AND customer_name IS SELECTED FROM orders);
As a result, the subquery will display the names of all of the customers whose ORDER_DATE is greater than February 1, 2023.