-1

I'm getting sql error for the below select

(select ((Select count(student_hash)from ssa.survey_results where question_master_id in (22)and center_id=101100 and answer_master_id in (95,96))*100/
(select (select case when exists((Select * from ssa.survey_results where question_master_id in (22)))then(Select count(student_hash)
from ssa.survey_results where question_master_id in (22))else 1 end)))As QUESTION22PERCENTAGE  from ssa.survey_results cd group by QUESTION22PERCENTAGE)Q22Percentage,

(select ((Select count(student_hash)from ssa.survey_results where question_master_id in (22)and answer_master_id in (95,96))*100/
(select (select case when exists((Select * from ssa.survey_results where question_master_id in (22)))then(Select count(student_hash)
from ssa.survey_results where question_master_id in (22))else 1 end)))As QUESTION22PERCENTAGE  from ssa.survey_results cd group by QUESTION22PERCENTAGE)Q22oPercentage,
(SELECT CASE WHEN Q22Percentage = Q22oPercentage THEN 'SAME'
            WHEN  Q22Percentage  > Q22oPercentage THEN 'BETTER'
            WHEN  Q22Percentage  < Q22oPercentage THEN 'WORSE'
            ELSE 'No comparison' END AS comparison)
            from  ssa.survey_results 
            group by Q22Percentage,Q22oPercentage;

I appreciate your help

ERROR: column "q22percentage" does not exist LINE 10: (SELECT CASE WHEN Q22Percentage = Q22oPercentage THEN 'SAME' ^

Evan Carroll
  • 65,432
  • 50
  • 254
  • 507
Dango
  • 1
  • 4

1 Answers1

1

The table ssa.survey_results does not have a column Q22Percentage

How much clearer can that message get?

Evan Carroll
  • 65,432
  • 50
  • 254
  • 507