Database Optimization

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
This technical problem deals with writing a SQL query to find the number of distinct values in each column of a table. The input is a table with two columns, and the output is the number of distinct values in each column.
About this solution: The solution above is optimal because it uses the COUNT function with the DISTINCT keyword. This will count the number of unique values in each column.
Jan 29
Databases / SQL DifficultyHard SQL
Query a database for customers who live in a given state and have made a purchase within the past 30 days.
About this solution: This is a good solution that demonstrates a level of completeness and solves the problem. The approach is efficient and uses the index on the state column to find all customers in the given state, and then filters out the ones who have not made a purchase in the past 30 days.
Nov 28
Databases / SQL DifficultyHard SQL
This technical problem deals with finding the second highest salary from a table of employees. An example table is given, along with the expected output.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also efficient, as it uses the ORDER BY and LIMIT clauses to sort the table by salary in descending order and then return the second highest salary.
Nov 27
Databases / SQL DifficultyHard SQL
Write a SQL query to find all pairs of rows in a table where the values in the two columns are within 10% of each other.
About this solution: This solution is correct and demonstrates a level of completeness. It solves the problem and uses the correct SQL syntax. The approach is straightforward and easy to understand.
Nov 22
Databases / SQL DifficultyHard SQL
To find the top 10 most common values in a given column with millions of rows, you can use a SQL query.
About this solution: The candidate's solution is optimal and demonstrates a complete understanding of the problem. The candidate has used the GROUP BY and ORDER BY clauses to group the values and order them by count, and the LIMIT clause to limit the number of rows returned.
Nov 20
Databases / SQL DifficultyMedium SQL
This technical problem involves writing a SQL query that returns the id, name, and salary of all employees with a salary greater than $50,000.
About this solution: The solution above is optimal because it uses the WHERE clause to filter the results.
Nov 07
Databases / SQL DifficultyMedium SQL
Write a SQL query to find the second highest salary from the employees table. The table has columns for id and salary. The query should return the salary column.
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 06