0
25% URI error. Why is the query not ordering? My query:
select distinct on (de.nome)
de.nome as name_dep,
di.nome as name_div,
coalesce(round(avg(ve.valor), 2) , 0) as avg_salary
from departamento de
inner join divisao di on di.cod_dep = de.cod_dep
inner join empregado em on em.lotacao_div = di.cod_divisao
inner join emp_venc ev on ev.matr = em.matr
inner join vencimento ve on ve.cod_venc = ev.cod_venc
group by de.nome, di.nome
order by de.nome, avg(ve.valor) desc
SQL: https://pastebin.com/7PyF9bDT
URI: https://www.urionlinejudge.com.br/judge/en/problems/view/2992
What do you consider "salary"? The sum of all salaries or any specific item? One should consider the discounts?
– anonimo
That’s a good question...not clear in the URI
– MARCOS DAVID ALMEIDA DE SOUSA
One possibility is to make a subselect that calculates the average salary of each division and that ratio select the highest average of each department.
– anonimo