TÓPICO

Wrong answer 100%

bsalazar0 perguntou 2 years ago

Hi sorry for not speaking Portuguese hope I get my doubts answered anyways,

I have two doubts what does the percentage mean when it says wrong answer and why am I not getting the question right since all my attempts have yield the same output as displayed

I will attach my codes as well as its result by the judge

Attempt #1

select c.name, 
sum((s.math*2)+(s.specific*3)+(project_plan*5)) / 10 as aver
from candidate c
join score s on
c.id = s.candidate_id
group by c.name
order by aver DESC;

Result: Wrong Answer (20%)

Attempt #2

select c.name, 
round(sum((s.math*2)+(s.specific*3)+(project_plan*5)) / 10,2) as aver
from candidate c
join score s on
c.id = s.candidate_id
group by c.name
order by aver DESC;

Result: Wrong Answer (100%)

Attempt #3

select c.name, 
trunc(sum((s.math*2)+(s.specific*3)+(project_plan*5)) / 10,2) as aver
from candidate c
join score s on
c.id = s.candidate_id
group by c.name
order by aver DESC;

Result: Wrong Answer (100%)

The attempts 2 and 3 is basically removing having lots of zero in the output of the first attempt

Thank you very much in advance and I would like to say that I am really loving your site is helping me to strengthen my SQL skills.

Lembre de não publicar soluções. Sua publicação pode ser revisada por nossos moderadores.

  • RubensBarbosaFilho respondido 2 years ago

    You are writting "avr" stead of "avg". You can use cast to convert to a decimal number. And at the end just order by avg desc