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 third highest salary in a table, you can use a SQL query. For example, given the following table: | ID | Name | Salary | |---- |-------|--------| | 1 | John | 1000 | | 2 | Jane | 2000 | | 3 | Joe | 3000 | | 4 | Sarah | 4000 | | 5 | Dave | 5000 | The third highest salary would be Joe's, with a salary of 3000.
About this solution: The candidate's solution is correct and uses the optimal approach to return the 3rd highest salary.
Nov 23
Databases / SQL DifficultyHard SQL
This technical problem involves writing a SQL query to find the average salary of employees by department. The example input table includes columns for department, first name, last name, and salary. The expected output is a table with columns for department and average salary.
About this solution: This solution is complete and solves the problem. The approach is straightforward and easy to follow.
Nov 23
Databases / SQL DifficultyHard SQL
The problem is to write a query to return the average price of all products in an unnormalized database table. The table includes the attributes productID, productName, productDescription, and productPrice.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate's approach is straightforward and solves the problem efficiently.
Nov 23
Databases / SQL DifficultyHard SQL
Given a database with two tables, Employees and Departments, this SQL query will find the names of all employees who work in the Sales department.
About this solution: The candidate's solution is complete and solves the problem. The approach is general and could be applied to other similar problems.
Nov 22
Databases / SQL DifficultyHard SQL
This technical problem deals with designing a social network database schema that includes posts, comments, and likes. The input is a set of CREATE TABLE statements for the three tables, and the output is sample data for those tables.
About this solution: The solution is optimal because it uses foreign keys to ensure data integrity.
Nov 22
Databases / SQL DifficultyHard SQL
To find the customer with the highest balance, you can use a simple SQL query as follows: SELECT customer_id, name, balance FROM customers ORDER BY balance DESC LIMIT 1
About this solution: The solution above is optimal because it uses the ORDER BY and LIMIT clauses to sort the table by balance in descending order and then return the first row.
Nov 22
Databases / SQL DifficultyHard SQL
Write a stored procedure that returns the name and salary of the highest paid employee from a table of data.
About this solution: The candidate's solution is correct and demonstrates a good understanding of how to solve the problem. The approach is efficient and uses a subquery to find the maximum salary, which is then used to return the name and salary of the employee with that salary.
Nov 22
Databases / SQL DifficultyHard SQL
Write a SQL query to find all pairs of distinct values in two columns.
About this solution: The solution above is optimal because it uses the DISTINCT keyword to remove duplicates.
Nov 22