Databases / SQL / Replication

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
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 asks the reader to write a SQL query that returns the names and total spending for customers who have made a purchase from the store in the last 30 days. The input is provided in the form of two tables, customers and orders, and the output is expected in the form of a table with two columns, name and total_spent.
About this solution: This solution is complete and solves the problem. It uses a JOIN to combine information from the customers and orders table and then uses the SUM function to calculate the total amount spent for each customer. The solution also uses the DATE_SUB function to only consider orders from the last 30 days.
Nov 21
Databases / SQL DifficultyMedium SQL
The goal is to find the total number of transactions for each user using data from two tables, "users" and "transactions". The "users" table has columns for id and name , while the "transactions" table has columns for id, user_id, and amount. The expected output is a table with columns for id, name, and total_transactions.
About this solution: The candidate's solution is correct and uses a LEFT JOIN to ensure that all users are included in the result, even if they have no transactions.
Nov 17
Databases / SQL SQL
Write a SQL query to find the most recent order for each customer in a database.
About this solution: The solution above is optimal because it uses a subquery to find the most recent order date for each customer.
Nov 15
Databases / SQL DifficultyMedium SQL
Write a SQL query to find the most recent order for each customer in a database.
About this solution: The solution above is optimal because it uses a subquery to find the most recent order date for each customer. This is the most efficient way to solve the problem.
Nov 12
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 SQL query to find customers who have placed an order with a value greater than $100. The example input provides sample data for a customers table and an orders table . The expected output is a list of customer ids and names who have placed an order with a value greater than $100.
About this solution: The solution above is optimal because it uses a JOIN to combine the two tables and then filters the results to only include customers who have placed an order with a value greater than $100.
Nov 07