Find users older than 20
Write a SQL query to find users whose age is greater than 20.
Problem index
Each problem has a crawlable detail page with schema, sample data, expected output, answer, explanation, common mistakes, and related concepts.
All problems
Use this index when you want a direct link to a specific problem page.
Write a SQL query to find users whose age is greater than 20.
Return only the product name and price columns from the products table.
List all orders so the most recent order appears first.
Return each customer_id and the number of orders placed by that customer.
Return the customer name, order id, and total amount for orders that have a matching customer.
Return orders whose total amount is greater than the average order amount.
Calculate the average salary for each department.
Return employees whose manager_id is NULL.
Find customer_id values that have placed at least two orders.
Return each order id and a size label: High for orders of 100 or more, otherwise Standard.
Return each product category only once from the products table.
Return orders created during January 2019 using a range condition.
Return the two products with the highest price.
Return the number of orders whose discount amount is greater than zero.
Return product categories whose average price is at least 50.
Return each customer email once for customers who ordered at least one product in the Gizmo category.
Return customers who do not have any matching rows in the orders table.
Return product titles for products that do not appear in any order.
Return student names for students who appear in the enrollments table.
Return each user's id and display name. Use nickname when it exists, otherwise use name.
Return each order with a rank number based on total_amount from highest to lowest within the same customer.
Return a single list of email addresses from customers and newsletter_signups without duplicates.
Return email values that appear more than once in the customers table.
Return each employee name with the name of their manager, keeping employees who have no manager.
Return the highest salary that is lower than the overall highest salary.
Return the highest priced product for each category.