How can I correct the error in the query? [URI 2992 Higher Average Wage Divisions]

Asked

Viewed 110 times

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

inserir a descrição da imagem aqui

  • What do you consider "salary"? The sum of all salaries or any specific item? One should consider the discounts?

  • That’s a good question...not clear in the URI

  • 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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.