Desafío de Empleados con un Salario Superior al Promedio
When a subquery is written in the WHERE section, we can use the IN operator and comparison operators:
Mencioné anteriormente que cuando una subconsulta se escribe en la sección WHERE, podemos utilizar el operador IN y los operadores de comparación.
Por ejemplo, así:
Swipe to start coding
Find employees whose salary is above the average salary of all employees using a subquery in the WHERE section.
The resulting table should have 3 columns: first_name, last_name, and salary. Then, sort the result by salary from highest to lowest using ORDER BY.
Note
This syntax can be used as a great alternative to the
HAVINGclause.
Brief Instructions
- Retrieve the
first_name,last_name, andsalarycolumns from theemployeestable. - In the
WHEREclause, use an inner query with the syntaxsalary > [inner query]. - In the inner query, get the average value of the
salarycolumn from theemployeestable. - Sort the results by
salaryin descending order.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 4
Desafío de Empleados con un Salario Superior al Promedio
Desliza para mostrar el menú
When a subquery is written in the WHERE section, we can use the IN operator and comparison operators:
Mencioné anteriormente que cuando una subconsulta se escribe en la sección WHERE, podemos utilizar el operador IN y los operadores de comparación.
Por ejemplo, así:
Swipe to start coding
Find employees whose salary is above the average salary of all employees using a subquery in the WHERE section.
The resulting table should have 3 columns: first_name, last_name, and salary. Then, sort the result by salary from highest to lowest using ORDER BY.
Note
This syntax can be used as a great alternative to the
HAVINGclause.
Brief Instructions
- Retrieve the
first_name,last_name, andsalarycolumns from theemployeestable. - In the
WHEREclause, use an inner query with the syntaxsalary > [inner query]. - In the inner query, get the average value of the
salarycolumn from theemployeestable. - Sort the results by
salaryin descending order.
Solución
¡Gracias por tus comentarios!
single