Databases / SQL

Categories: Code Problem / Data Structures and Algorithms / Recursion (32) Code Problem / Data Structures and Algorithms / Binary Search (30) Code Problem / Data Structures and Algorithms / Linked Lists (26) Code Problem / Data Structures and Algorithms / Backtracking (26) Code Problem / Data Structures and Algorithms / Stacks and Queues (25) Code Problem / Data Structures and Algorithms / Hashing (24) Databases / SQL / Backup and Recovery (19) Code Problem / Data Structures and Algorithms / Arrays and Strings (19) Databases / SQL / Database Normalization (18) Code Problem / Data Structures and Algorithms / Time Complexity (17) Databases / SQL / Locking (16) Databases / SQL / Replication (15) Databases / SQL / SQL Queries (13) Code Problem / Data Structures and Algorithms / Graphs (13) Databases / SQL / Database Security (13)  More...

Recent solutions:

Check these solutions from our community:
Databases / SQL DifficultyHard SQL
Write a stored procedure that returns the total number of employees in each department from a given table of employee data.
About this solution: This solution is correct and demonstrates a good understanding of SQL.
Nov 26
Databases / SQL DifficultyHard SQL
This technical problem asks the reader to write a SQL query to find the average order value for each customer, given a table of customer orders. An example input and output is provided.
About this solution: The solution above is optimal because it uses the GROUP BY clause to group the orders by customer_id, and then uses the AVG function to calculate the average order value for each customer.
Nov 26
Databases / SQL DifficultyHard SQL
This technical problem asks the reader to write a SQL query to find the second highest salary from a given table of employees. An example table is provided, along with the expected output.
About this solution: The solution above is optimal because it uses a subquery to find the maximum salary and then uses that value to find the second highest salary.
Nov 26
Databases / SQL DifficultyHard SQL
Given a table with two columns, id and value, write a query to find the id of the row with the maximum value.
About this solution: The candidate's solution is correct and demonstrates a good understanding of how to find the maximum value in a table. The solution is also efficient, as it only requires one pass through the table.
Nov 26
Databases / SQL DifficultyHard SQL
Write a SQL query that returns the names of all the people who have a score greater than 80.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL.
Nov 26
Databases / SQL DifficultyHard SQL
Write a trigger that will update the total salary for each department when an employee's salary is updated.
About this solution: The trigger above is a good solution that solves the problem. It is efficient because it only updates the department table when the employee table is updated.
Nov 26
Databases / SQL DifficultyHard SQL
This technical problem involves finding all customers who have ordered a product that is out of stock. The input is three tables: customers, orders, and products. The output is the customers table with the id and name of the customers who have ordered a product that is out of stock.
About this solution: The solution is correct and demonstrates a level of completeness. It solves the problem and uses the correct approach.
Nov 25
Databases / SQL DifficultyHard SQL
To find the most common value in a table with two columns, you can use a SQL query. For example, given the table above, the query would return 3 as the most common value in the second column.
About this solution: The solution above is optimal because it uses the GROUP BY and ORDER BY clauses to group the values and order them by count. The LIMIT clause is used to limit the result to one row.
Nov 25