
SQL Code Challenges & Tips
- 10 Topics

1. Write a SQL query to find the second highest salary from a table named `employees`.
2. Write a SQL query to retrieve the names of employees who have the same salary as the average salary of their department from the `employees` table.
3. Write a SQL query to isolate and return the 10 most recent orders from an `orders` table, ordered by order date.
4. Write a SQL query to count the number of employees in each department, ensuring no department with zero employees is returned, using the `employees` and `departments` tables.
5. Write a SQL query to find all products that have never been ordered from a `products` table and an `order_details` table.
6. Write a SQL query to retrieve the names of employees who have worked for the company for more than five years, sorted by their hire date.
7. Write a SQL query to create a new table `top_performers` that contains the details of employees whose sales figures are in the top 10% of all employee sales from the `sales` table.
8. Write a SQL query to find the total sales made by each salesperson, grouped by the salesperson's ID, and sorted in descending order of total sales.
9. Write a SQL query to return the employee ID and the number of projects they are assigned to, from an `employees` table and a `projects` table. Only include employees with more than one project.
10. Write a SQL query to retrieve all the categories from the `products` table that have not sold any items, using the `categories` and `sales` tables.
Reveal all the approved answers to the questions above and explore all the types of SQL questions and answers.
Explore Now