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
To find the second highest salary from a SQL database, you can use a subquery. This subquery will return the salary of the employee with the second highest salary.
About this solution: The candidate's solution is correct and demonstrates a good understanding of how to use the ORDER BY, LIMIT, and OFFSET clauses in SQL to solve the problem.
Nov 19
Databases / SQL DifficultyHard SQL
Given two tables, "A" and "B", write a SQL query to find all the rows from table "A" that have no corresponding rows in table "B".
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The approach is sound and the solution is complete.
Nov 19
Databases / SQL DifficultyMedium SQL
To get customers who have made a purchase in the last 30 days, write a SQL query that returns all customers with a purchase_date within the last 30 days.
About this solution: The solution above is a good solution that demonstrates a level of completeness and solves the problem. The approach is also good, using the DATE_SUB function to subtract 30 days from the current date. This is optimal because it will always return the correct results, regardless of the current date.
Nov 18
Databases / SQL DifficultyMedium SQL
The goal is to find the average price of all products in the "Electronics" category. To do this, we can write a SQL query that returns the average price of all products in the "Electronics" category.
About this solution: The solution is correct and uses the WHERE clause to filter the results to only the products in the "Electronics" category.
Nov 18
Databases / SQL DifficultyMedium SQL
This technical problem deals with writing a SQL query to find the most recent date for each unique value in a table. The table given in the example has two columns, one for dates and one for unique values. The expected output is also given in the example.
About this solution: The solution above is optimal because it uses a subquery to find the most recent date for each unique value. This is the most efficient way to solve the problem and will work for any size table.
Nov 18
Databases / SQL DifficultyMedium SQL
Given a table of transactions, this SQL query will find the total value of all transactions for each day.
About this solution: The solution above is optimal because it uses the GROUP BY clause to group the transactions by date. The SUM function is used to sum the values of each group.
Nov 18
Databases / SQL DifficultyMedium SQL
This stored procedure calculates the number of days between two dates.
About this solution: This solution is correct and efficient.
Nov 18
Databases / SQL DifficultyMedium SQL
Given a table of data with two columns, write a SQL query to find the median value in the second column.
About this solution: The candidate's solution is correct and uses the median function, which is a built-in function in SQL.
Nov 18