在我的查询中,我必须检查三个条件并加入,哪里是常见的..但是这个
中有一些错误 select
count(case when interview_status = 1 then applicant_id else null end) as selected,
count(case when interview_status = 2 then applicant_id else null end) as rejected,
count(case when interview_status = 3 then applicant_id else null end) as not_attented,
JOIN appointment ON appointment.applicant_id=student_application.applicant_id,
WHERE filter_status=1 AND appointment_status !=0
from student_application;
但是这显示了一些错误
答案 0 :(得分:2)
,
的问题。 from
子句应在where
之前
select
count(case when interview_status = 1 then applicant_id else null end) as selected,
count(case when filter_status = 2 then applicant_id else null end) as rejected,
COUNT(CASE WHEN FILTER_STATUS = 2 THEN APPLICANT_ID ELSE NULL END) AS NOT_ATTENTED
from student_application
JOIN appointment ON appointment.applicant_id=student_application.applicant_id
WHERE FILTER_STATUS=1 AND APPOINTMENT_STATUS !=0;