Write a SQL query to find the second highest salary from the employees table.
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 deals with writing a SQL query to find all parents who have at least one child. The example input and output are provided in the body of the problem.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also efficient, using a JOIN to combine the two tables and then using DISTINCT to remove any duplicate rows.
The average salary of all employees in a company can be found using a SQL query. For example, if the employees table contains the following columns: ID, NAME, and SALARY, the average salary can be calculated by querying the table for the average value of the SALARY column.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The solution is also optimal, as it is the simplest solution that will return the correct result.
Write a SQL query to sum the balances of all rows with an id greater than 5.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate has correctly used the SUM function to add up the balances of all rows with an id that is greater than 5.
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.
To find the top 5 most expensive items in the database, write a SQL query that orders the items by price in descending order.
About this solution: The solution above is optimal because it uses the ORDER BY and LIMIT clauses to sort the items by price in descending order and then limit the results to the top 5 items.