我正在尝试创建查询优化过程,但无法创建,这是我的SQL:
DELIMITER $$
CREATE ` PROCEDURE `vaars_test_latest`.`geterpdata`(IN applicant_id VARCHAR(255))
BEGIN
SELECT
t2.start_date AS date_from_ad,
t2.end_date AS date_to_ad,
t1.job_id,
t1.org_id,
t1.seniority_date_bs AS seniority_date_bs,
t1.seniority_Date AS seniority_date_ad,
t5.name_en AS working_office,
t5.id AS working_office_id,
t7.name_en AS designation,
t7.id AS designation_id,
t8.name_en AS service_group,
t8.id AS service_group_id,
t9.name_en AS work_level,
t9.id AS work_level_id,
CASE
WHEN t1.incharge = 1 THEN 'YES'
ELSE 'NO'
END AS is_office_incharge,
CASE
WHEN t1.incharge = 1 THEN t1.start_date
ELSE NULL
END AS incharge_date_from_ad,
CASE
WHEN t1.incharge = 1 THEN t1.end_date
ELSE NULL
END AS incharge_date_to_ad
FROM
erp_service_history t1
LEFT JOIN
temp1 t2
ON t1.emp_no = t2.emp_no
AND t1.job_id = t2.job_id
AND t1.org_id = t2.org_id
INNER JOIN
applicant_profile t4
ON t4.nt_staff_code = t1.emp_no
LEFT JOIN
erp_organization t3
ON t3.id = t1.org_id
LEFT JOIN
mst_working_office t5
ON t5.id = t3.working_office_id
LEFT JOIN
erp_jobs t6
ON t6.id = t1.job_id
LEFT JOIN
mst_designation t7
ON t7.id = t6.designation_id
LEFT JOIN
mst_work_service_group t8
ON t8.id = t6.service_group_id
LEFT JOIN
mst_work_level t9
ON t9.name_en = t1.grade
WHERE
t1.seniority_Date = t2.seniority_Date AND t4.id = applicant_id
ORDER BY
t2.start_date DESC ;
END$$
DELIMITER ;
并引发以下异常:
查询执行失败 原因: SQL错误[1064] [42000]:您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以找到在第61行的''附近使用的正确语法
第61行是逐行订购的,请提供帮助。