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
Given a database table with a schema as shown above, write a SQL query that returns the total value of all products in the table.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also optimal, as it is a single query that does not require any joins or subqueries.
Nov 21
Databases / SQL DifficultyHard SQL
This technical problem asks the reader to write a SQL query that returns the names and total spending for customers who have made a purchase from the store in the last 30 days. The input is provided in the form of two tables, customers and orders, and the output is expected in the form of a table with two columns, name and total_spent.
About this solution: This solution is complete and solves the problem. It uses a JOIN to combine information from the customers and orders table and then uses the SUM function to calculate the total amount spent for each customer. The solution also uses the DATE_SUB function to only consider orders from the last 30 days.
Nov 21
Databases / SQL DifficultyHard SQL
Design a database schema for a library system that keeps track of books, patrons, and checkouts. The system should allow patrons to check out multiple books at a time, and should keep track of when books are due back.
About this solution: This solution is a good start, but it is missing a few key details. For example, it does not specify what information is stored in each table. In addition, the solution does not address how the system will keep track of which books are available and which are checked out.
Nov 21
Databases / SQL DifficultyHard SQL
Given a table of employee data, write a SQL query to find the highest paid employee.
About this solution: The candidate's solution is optimal and demonstrates a complete understanding of the problem. The candidate's approach is straightforward and easy to follow.
Nov 20
Databases / SQL DifficultyHard SQL
Given a table of data with three columns: id, start, and end, this SQL query will find all pairs of rows where the start and end times overlap.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also optimal, as it uses a JOIN to find all pairs of rows that overlap.
Nov 20
Databases / SQL DifficultyHard SQL
You are tasked with creating a backup and recovery plan for a database. The database is currently running on a single server. The backup plan must be able to recover the database in the event of a server failure.
About this solution: The candidate's solution is complete and solves the problem. The approach is straightforward and should work well in most cases.
Nov 20
Databases / SQL DifficultyHard SQL
Given a table with two columns, find the most common value in each column using a SQL query.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also efficient, using the GROUP BY and ORDER BY clauses to group and order the rows by the values in each column, and then using the LIMIT clause to return only the first row.
Nov 20
Databases / SQL DifficultyHard SQL
This technical problem involves writing a query to find the number of items that are locked by each user in a given table. The output should show the user ID and the number of items locked for each user.
About this solution: This solution is complete and solves the problem. The approach is straightforward and easy to follow.
Nov 20