Check these solutions from our community:

Write a SQL query that returns the total quantity of each product ordered by each customer.

About this solution: The candidate's solution correctly returns the total quantity of each product ordered by each customer. The solution uses the GROUP BY clause to group the customer and product IDs together, and then uses the SUM function to calculate the total quantity for each group. The solution is clear and concise.

This technical problem involves writing an SQL query that returns the top 3 most purchased products by customers. The example input and output are provided.

About this solution: The solution above is optimal because it uses the ORDER BY and LIMIT clauses to sort the table by product_id in descending order and then limit the results to the top 3.

This problem asks for a SQL query to find all users in a table who have a valid email address.

About this solution: The solution correctly uses the LIKE operator to check if the email contains an @ symbol.

Databases / SQL
SQL

Given a list of customer names and their purchase amounts, this SQL query will find the total amount spent by each customer.

About this solution: The solution provided is correct and demonstrates a good understanding of SQL. The approach is clear and concise.

Databases / SQL
SQL

This technical problem deals with creating a function that will take in an array of integers and return the sum of all the even numbers in the array.

About this solution: The candidate's solution correctly calculates the sum of all even numbers in the array. However, the solution could be more concise. For example, the candidate could have used the built-in SUM function to calculate the sum, rather than creating a new table.

Databases / SQL
SQL

Write a SQL query to find the products with the highest price from a given table.

About this solution: The candidate's solution is correct and solves the problem. The approach is straightforward and easy to understand.

Databases / SQL
SQL

This technical problem deals with creating a function that will take in an array of integers and return the sum of all the even numbers in the array.

About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate's approach is also optimal, making use of a CASE statement to check if the number is even and then returning the number if it is even and 0 if it is not. The SUM function then adds up all the numbers in the column.

Databases / SQL
SQL

This problem deals with using a cursor to loop through a table of employee data in order to print the employee's name and salary.

About this solution: The candidate's solution is complete and solves the problem. The candidate has used a cursor to loop through the table and print the employee's name and salary. This is the optimal solution.