PostGreSQL compilation error - Error

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) the "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:

link

    
asked by anonymous 05.11.2018 / 21:07

1 answer

3

You need to put the multiplications inside the parentheses (ex: SCO.MATH 2). Another thing is that in the alias can not put single quotes (''), cause error.

The query would look like:

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;

Result:

    
27.11.2018 / 14:45