Last answered:

21 Apr 2023

Posted on:

20 Apr 2023

1

Resolved: Why a subquery?

Why in this query we use a subquery? 

select a.emp_no,
max(salary) as max_salary from
(select emp_no, salary
from salaries) a group by emp_no;

Is this for the learning purpose?

Can we just use the following query with the same result?

select emp_no,
max(salary) as max_salary 
from salaries  group by emp_no;

1 answers ( 1 marked as helpful)
Instructor
Posted on:

21 Apr 2023

1

Hi Eugenia!
Thanks for reaching out.


Yes, you can use both queries. The idea is to practise subqueries.


Hope this helps.
Best,
Tsvetelin

Submit an answer