Sektion 2. Kapitel 4
single
Udfordring: Medarbejdere med Højere end Gennemsnitlig Løn
Stryg for at vise menuen
Når en underforespørgsel skrives i WHERE-sektionen, kan du bruge IN-operatoren og comparison operators:
SELECT column1, ...
FROM table
WHERE column1 > (SELECT AGG(column2) FROM table)
Opgave
Swipe to start coding
Find employees whose salary is above the average salary of all employees using a subquery in the WHERE clause.
The resulting table should contain 3 columns: first_name, last_name, and salary. Then, sort the result by salary in descending order using ORDER BY.
This syntax serves as an excellent alternative to the HAVING clause.
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, calculate the average value of the
salarycolumn from theemployeestable. - Sort the results by
salaryin descending order.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 4
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat