I have the following exercise:
List department code and name, the earliest and oldest admission date of each department, sort by department name.
I was able to do the following:
select d.department_id, d.department_name, max(jh.start_date), min(jh.start_date) from departments d
inner join job_history jh on jh.department_id = d.department_id
group by d.department_id order by d.department_name;
But the error below, would like to know why it happens and how to solve.
ORA-00979: não é uma expressão GROUP BY 00979. 00000 - "not a GROUP BY expression" *Cause: *Action: Erro na linha: 45 Coluna: 25