Select All Employees
Write a query to select all columns from the employees table. Return columns: id, first_name, last_name, email, department_id, salary, hire_date, manager_id.
Practice SQL online with 300 interactive challenges built around realistic data. Start with 92 free exercises, get instant feedback, and progress from SELECT basics to Advanced SQL.
Open the schema, inspect the sample data, run your answer, and see the result immediately.
Write a query to select all columns from the employees table. Return columns: id, first_name, last_name, email, department_id, salary, hire_date, manager_id.
Write a query to retrieve only the first_name and last_name of all employees. Return columns: first_name, last_name.
Find employees with a salary greater than 80,000 and show id, first_name, last_name, and salary. Return columns: id, first_name, last_name, salary.
Find all employees in department_id = 1 (Engineering), showing their name and salary. Return columns: first_name, last_name, salary.
List all employees ordered by salary from highest to lowest. Return columns: first_name, last_name, salary. Order results by: salary DESC.
Count the number of employees in each department. Return columns: department_id, employee_count. Order results by: department_id.
Calculate the average salary for each department. Return columns: department_id, avg_salary. Order results by: department_id.
Find all employees who do not have a manager (manager_id is NULL). Return columns: id, first_name, last_name.
Count how many orders have the status 'completed'. Return columns: completed_count.
List the top 3 most expensive products with their names and prices. Return columns: name, price. Order results by: price DESC.
List each employee's full name alongside their department name. Use INNER JOIN. Return columns: first_name, last_name, department_name.
Find departments where the average salary is greater than 75,000. Return columns: department_id, avg_salary. Order results by: department_id.
Find all customers who have never placed an order. Return columns: id, name, email.
Calculate total revenue (sum of total_amount) per customer, showing customer name and total revenue, sorted by revenue descending. Return columns: customer_name, total_revenue. Order results by: total_revenue DESC.
Find employees whose salary is higher than the average salary of their department. Return columns: first_name, last_name, salary, department_id.
For each product, show the total quantity sold and total revenue from order_items. Include product name. Return columns: product_name, total_quantity, total_revenue. Order results by: total_revenue DESC.
Count how many employees were hired in each year, ordered by year ascending. Return columns: hire_year, employee_count. Order results by: hire_year ASC.
Create a full_name column by concatenating first_name and last_name with a space between them. Return columns: full_name, email.
Rank employees by salary within each department using RANK(), then return each employee's department, salary, and position. Return columns: first_name, last_name, department_id, salary, salary_rank. Order results by: department_id, salary_rank.
Calculate a chronological running total of order amounts and return every order with its date, amount, and cumulative revenue. Return columns: id, order_date, total_amount, running_total. Order results by: order_date.
Using a CTE, find the highest-paid employee in each department. Return columns: department_id, first_name, last_name, max_salary. Order results by: e.department_id.
Summarize monthly order volume and revenue, then compare each month with the previous month using LAG(). Return columns: month, orders, revenue, prev_revenue, revenue_change. Order results by: month.
Divide employees into four salary quartiles with NTILE(4), then return each employee's name, salary, and quartile. Return columns: first_name, salary, quartile. Order results by: salary DESC.
Use a self LEFT JOIN to list every employee with their direct manager's first name. Return columns: id, first_name, manager_name. Order results by: e.id.
Calculate how many customers from each acquisition month (cohort) placed orders in their first month. Return columns: cohort_month, cohort_size, first_month_orders, retention_rate. Order results by: c.cohort_month.
List employee names and salaries between 70,000 and 90,000, ordered by salary. Return columns: first_name, last_name, salary. Order results by: salary.
Show employee last names, first names, and emails alphabetically by last name. Return columns: last_name, first_name, email. Order results by: last_name, first_name.
Find products with fewer than 200 units in stock, cheapest first. Return columns: name, category, price, stock. Order results by: price.
Count customers in each country, sorted by the country name. Return columns: country, customer_count. Order results by: country.
Calculate the combined budget of all departments. Return columns: total_budget.
List pending orders with their date and total amount. Return columns: id, order_date, total_amount. Order results by: order_date.
Show every product name in uppercase alongside its category. Return columns: product_name, category. Order results by: id.
List customers who joined on or after January 1, 2021. Return columns: name, country, joined_date. Order results by: joined_date.
Show each department name, employee count, and total payroll. Return columns: department_name, employee_count, total_payroll. Order results by: d.id.
Show all departments and their employee count, including departments with no employees. Return columns: department_name, employee_count. Order results by: d.id.
Show the order count and total amount for each status. Return columns: status, order_count, total_amount. Order results by: status.
Find customers who placed more than one order. Return columns: customer_name, order_count. Order results by: order_count DESC, customer_name.
Show every product and its revenue, using zero when it has no sales. Return columns: product_name, revenue. Order results by: p.id.
List each managed employee together with their manager's name. Return columns: employee, manager. Order results by: e.id.
Find orders whose total amount is greater than the average order value. Return columns: id, customer_id, total_amount. Order results by: total_amount DESC.
Extract the portion of each employee email before the @ symbol. Return columns: email, username. Order results by: id.
Calculate completed-order revenue for each month. Return columns: month, revenue. Order results by: month.
Calculate inventory value for products with fewer than 200 units. Return columns: name, stock, price, inventory_value. Order results by: inventory_value DESC.
Use DENSE_RANK() to rank products by price inside each category while keeping equal prices at the same rank. Return columns: name, category, price, price_rank. Order results by: category, price_rank, name.
Number each customer's orders chronologically with a window function and return the customer, order date, and sequence number. Return columns: customer_id, order_id, order_date, order_number. Order results by: customer_id, order_number.
Use a CTE to return the three highest-paid employees. Return columns: first_name, last_name, salary, salary_rank. Order results by: salary_rank.
Calculate each employee's percentage share of their department payroll. Return columns: first_name, department_id, salary, payroll_share. Order results by: department_id, salary DESC.
Compare every order amount with the previous chronological order using LAG(), while preserving the complete order sequence. Return columns: id, order_date, total_amount, previous_amount. Order results by: order_date, id.
Find customers who purchased products from both Software and Infrastructure. Return columns: customer_name, category_count. Order results by: c.name.
Calculate the number of days between each customer's consecutive orders while retaining the current and previous order dates. Return columns: customer_id, order_id, order_date, previous_order_date, days_since_previous. Order results by: customer_id, order_date.
List employee names and salaries above 60000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
List employee names and salaries above 65000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
List employee names and salaries above 70000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
List employee names and salaries above 75000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
List employee names and salaries above 80000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
List employee names and salaries above 85000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
List employee names and salaries above 90000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
List employee names and salaries above 100000, ordered by salary descending. Return columns: first_name, last_name, salary. Order results by: salary DESC, id.
Return employee names and salaries below 60000, lowest salary first. Return columns: first_name, last_name, salary. Order results by: salary, id.
Return employee names and salaries below 65000, lowest salary first. Return columns: first_name, last_name, salary. Order results by: salary, id.
Showing the first 60 of 300 challenges in this learning path.
Browse and filter all challenges in the Practice ArenaFollow analyst-focused exercises for free, or unlock all 300 Core and Advanced challenges with Pro.
Structured SQL practice
Start with a topic you can explain in plain language, inspect the schema, write the smallest correct query, and validate the result. Move from SELECT and filtering to JOINs, grouped reports, CTEs and window functions as your accuracy improves.