Databases

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 DifficultyMedium SQL
This question asks for the 5th highest salary from the "Employees" table. The example input is a table with id, name, and salary columns, and the example output is a table with a salary column.
About this solution: The solution above is optimal because it uses the LIMIT clause to limit the number of rows returned by the query.
Feb 02
Databases / SQL DifficultyHard SQL
This technical problem deals with finding common records between two SQL tables. An example is given, along with the expected output.
About this solution: The candidate's solution is correct and uses an inner join, which is the most efficient way to find common records between two tables.
Jan 31
Databases / SQL DifficultyHard SQL
To find the id and value of the row with the highest value in a table with two columns, id and value, write a query that will return the id and the value of the row with the highest value.
About this solution: The solution above is optimal because it uses the ORDER BY and LIMIT clauses to sort the table by value in descending order and then return the first row.
Jan 31
Databases / SQL DifficultyHard SQL
This technical problem asks the reader to write a SQL query to find the top 10 customers by total spend. The table of customer data is provided as an example, and the expected output is also provided.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is optimal, using the ORDER BY and LIMIT clauses to sort the table by total_spend in descending order and then limit the results to the top 10 customers.
Jan 31
Databases / SQL DifficultyHard SQL
You are given two tables, Table A and Table B. Your task is to write a SQL query that returns the sum of the values in Table A, multiplied by the sum of the values in Table B.
About this solution: This solution is correct and demonstrates a level of completeness. It correctly calculates the sum of the values in table A and table B, and then multiplies them together.
Jan 30
Databases / SQL DifficultyHard SQL
This stored procedure will take in a table name and column name as input, and return all the unique values in that column as output.
About this solution: The solution above is optimal because it uses the DISTINCT keyword to return only unique values.
Jan 30
Databases / SQL DifficultyHard SQL
This technical problem deals with how to query XML data in SQL in order to return it in a tabular format.
About this solution: This solution is correct and uses the XML data type's built-in methods to parse the XML data, which is optimal.
Jan 30
Databases / SQL DifficultyHard SQL
This question asks for a cursor that will print the id, start, and end times for each row in a table. The input table has three columns: id, start, and end. The example output should print the id and start and end times for each row in the table, as shown in the example output.
About this solution: The solution above is optimal because it is the simplest solution that will work.
Jan 29