Conteúdo do Curso
SQL Intermediário
SQL Intermediário
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 begin your solution
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
HAVING
clause.
Brief Instructions
- Retrieve the
first_name
,last_name
, andsalary
columns from theemployees
table. - In the
WHERE
clause, use an inner query with the syntaxsalary > [inner query]
. - In the inner query, get the average value of the
salary
column from theemployees
table. - Sort the results by
salary
in descending order.
Solução
Obrigado pelo seu feedback!
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 begin your solution
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
HAVING
clause.
Brief Instructions
- Retrieve the
first_name
,last_name
, andsalary
columns from theemployees
table. - In the
WHERE
clause, use an inner query with the syntaxsalary > [inner query]
. - In the inner query, get the average value of the
salary
column from theemployees
table. - Sort the results by
salary
in descending order.
Solução
Obrigado pelo seu feedback!