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 DifficultyMedium SQL
This technical problem involves writing a SQL query to find all customers who have placed an order in the last 30 days. The example input data consists of a customers table with id and name columns, and an orders table with id, customer_id, and order_date columns. The example output lists the id and name columns for all customers who have placed an order in the last 30 days.
About this solution: This solution is complete and solves the problem. The approach is to join the customers and orders table on the customer id and then filter for orders that have been placed in the last 30 days. This approach is sensible and efficient.
Nov 12
Databases / SQL DifficultyMedium SQL
This technical problem asks the reader to write a SQL query that finds the most recent backup for each database on a server. The example input provided shows two databases, each with a different last backup date. The expected output is the same as the input.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL.
Nov 12
Databases / SQL DifficultyMedium SQL
Write a SQL query to find the most recent order date for each customer in a given table. The table should have the following columns: customer_id, customer_name, order_date .
About this solution: The solution above is optimal because it uses the MAX function to find the most recent order date for each customer.
Nov 12
Databases / SQL DifficultyMedium SQL
To find the employees who have been with the company for more than 5 years, we can write a SQL query that uses the StartDate column in the table to filter the results.
About this solution: This solution is correct and demonstrates a level of completeness. It solves the problem and uses a reasonable approach.
Nov 12
Databases / SQL DifficultyMedium SQL
This technical problem deals with calculating the average salary for each department using a cursor. Given a table of employees and their salaries, the cursor will iterate over the table and calculate the average salary for each department. The output will be a table with the department ID and the corresponding average salary.
About this solution: This solution is correct and demonstrates a good understanding of how to calculate averages in SQL.
Nov 11
Databases / SQL DifficultyMedium SQL
Given a table of customer data, write a SQL query to find the names of all customers who live in the same city as the customer with the name 'John Smith'.
About this solution: The solution above is optimal because it uses a subquery to find the city of John Smith, and then uses that city to find all customers who live in that city.
Nov 11
Databases / SQL DifficultyMedium SQL
This technical problem involves writing a SQL query to find the total number of items ordered for each order in a database. The database consists of two tables, "orders" and "order_items ". The "orders" table includes the order_id for each order, while the "order_items" table includes the order_id and the number of items ordered for that particular order. The expected output is a table that lists the order_id and the total number of items ordered for each order.
About this solution: The candidate's solution is correct and uses an optimal approach.
Nov 11
Databases / SQL DifficultyMedium SQL
This technical problem involves writing a function that takes a string and a character as arguments, and returns the number of times the character appears in the string.
About this solution: The solution provided is a valid solution that uses built-in functions to solve the problem. The approach is sound and the solution is complete.
Nov 11