Postgresql build error - Error

Asked

Viewed 58 times

2

I’m trying to run this query in postgresql but it gives compilation error:

select can.name as 'name', ( ( (sco.Math 2) + ( sco.specific1 3 ) + ( sco.project_plan * 5 ) /10 ) as "avg" from candidate can Join score sco on can.id = sco.candidate_id order by "avg" desc;

The problem is described in the link below:

https://www.urionlinejudge.com.br/judge/pt/problems/view/2738

  • which build error? face can already say that alias with simple quote will give error even (in 'name')

  • I can’t tell because it’s a problem I’m solving on Ri and I don’t have this database installed on my pc

  • And "name" didn’t work either :(

  • select can.name as 'name', ... Must be "name" with double quotes. It is not a string but an identifier, see Quoted.

1 answer

3


Ta missing to put the multiplications inside the parentheses (ex: SCO.MATH 2) . Another thing is that in alias can not put simple quotes ( '' ), causes error.

The query would be:

SELECT CAN.NAME AS NAME,
   ( ( (SCO.MATH * 2) + ( SCO.SPECIFIC * 3 ) + ( SCO.PROJECT_PLAN * 5 ))/10) AS AVG
FROM CANDIDATE CAN JOIN SCORE SCO ON CAN.ID = SCO.CANDIDATE_ID 
ORDER BY AVG DESC;

Upshot:

inserir a descrição da imagem aqui

  • Thanks was that the problem! It helped a lot believe.

Browser other questions tagged

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