Desafio dos Funcionários com Salário Acima da Média
When a subquery is written in the WHERE section, we can use the IN operator and comparison operators:
Eu mencionei anteriormente que quando uma subconsulta é escrita na seção WHERE, podemos usar o operador IN e os operadores de comparação.
Por exemplo, assim:
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.
Solução
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Can you explain how the IN operator works with subqueries?
What are some examples of comparison operators I can use in subqueries?
Can you show a practical example using both IN and a comparison operator in a WHERE clause?
Incrível!
Completion taxa melhorada para 4
Desafio dos Funcionários com Salário Acima da Média
Deslize para mostrar o menu
When a subquery is written in the WHERE section, we can use the IN operator and comparison operators:
Eu mencionei anteriormente que quando uma subconsulta é escrita na seção WHERE, podemos usar o operador IN e os operadores de comparação.
Por exemplo, assim:
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.
Solução
Obrigado pelo seu feedback!
single