Check these solutions from our community:

Databases / SQL
SQL

This technical problem involves writing a SQL query that returns the total revenue for each customer. The table schema is provided, and an example input and output are also given.

About this solution: This solution is complete and solves the problem. The approach is straightforward and easy to follow.

This technical problem asks the reader to write a SQL query to find the second highest salary from a given table of employees. An example table is provided, along with the expected output.

About this solution: The solution above is optimal because it uses a subquery to find the maximum salary and then uses that value to find the second highest salary.

This technical problem involves writing a SQL query to find products with a price greater than the average price of all products.

About this solution: The candidate's solution is correct and demonstrates a level of completeness. The solution solves the problem and uses the correct SQL syntax. The candidate's approach is efficient because it only requires one query to the database.

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.

Given a database table with a schema as shown above, write a SQL query that returns the total value of all products in the table.

About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also optimal, as it is a single query that does not require any joins or subqueries.

The table given contains information on employees, including their ID, name, manager ID, and department. The goal is to write a SQL query that returns the ID and name of all employees who are not managers and who are in the Sales department. From the given example input, the expected output would be the ID and name of Joe and Karen.

About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The candidate has correctly used the WHERE clause to filter out the rows that do not meet the criteria. The candidate has also correctly used the IS NULL operator to check for employees who are not managers.

Given a table with two columns, "name" and "parent", write a SQL query to find all the children of the parent "A".

About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also efficient, using the WHERE clause to filter the results.

To find the third highest salary in a table, you can use a simple ORDER BY and LIMIT clause in SQL.

About this solution: The candidate's solution is correct and uses an optimal approach.