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
A system that can support 1,000 concurrent users is needed.
About this solution: The candidate's solution is incomplete. The candidate does not mention how to design the system to support a large number of concurrent users. The candidate only mentions horizontal scaling, which is one approach to scaling. The candidate does not mention other approaches, such as vertical scaling, which could also be used to support a large number of concurrent users.
Nov 18
Databases / SQL DifficultyMedium SQL
To find the total number of orders for each customer, you can use a SQL query as follows: SELECT customer_id, COUNT(order_id) AS total_orders FROM customer_orders GROUP BY customer_id;
About this solution: The candidate's solution is correct and uses an optimal approach.
Nov 18
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 DifficultyMedium SQL
This technical problem deals with writing a SQL query to find the number of users who have both a first and last name. The input is a table of user data, and the output is the number of users who have both a first and last name.
About this solution: The solution above is correct and demonstrates a level of completeness. It solves the problem and takes the optimal approach by only counting the number of users who have both a first and last name.
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 that returns the 5 most recent articles from a table of articles, sorted by published date.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is optimal because it uses the ORDER BY and LIMIT clauses to sort the articles by published date in descending order and then limit the results to the 5 most recent articles.
Nov 15
Databases / SQL DifficultyMedium SQL
Given a table of customer data, this SQL query returns the top 10 customers with the highest average order value.
About this solution: The candidate's solution is complete and solves the problem. The approach is clear and concise.
Nov 15
Databases / SQL DifficultyMedium SQL
This technical problem deals with returning the value of an XPath expression from an XML document using a SQL query.
About this solution: The candidate's solution is complete and solves the problem. The candidate has used the XMLTABLE function to parse the XML document and return the value of the XPath expression.
Nov 15