在第一个“;”之后我不断收到 1064 语法错误 在第一个 when 语句中。我试图从这里和这里获得提示都无济于事。帮助任何人?
DELIMITER //
CREATE PROCEDURE `test` ()
BEGIN
SELECT *,
case
when variable_1 between 0.75 and 4 then 4;
when variable_1 between 0 and 0.74 then "<4";
when variable_1 between 4.1 and 365 then ">4";
end case as variable_2;
END //
修改后的问题:
实际代码:
DELIMITER //
CREATE PROCEDURE `infant_outcomes`.`new_procedure` ()
BEGIN
SELECT * FROM CDI
INNER JOIN
-- CDI subquery grouping and filtering
(SELECT CDI.subj_CDI as subj_CDI_grouping, Min(hearing_age_CDI) min_hearing_age_CDI,
case
when CDI.hearing_age_CDI between 1.75 and 4.25 then 3
when CDI.hearing_age_CDI between 4.75 and 7.25 then 6
end as hearing_age_CDI_group
FROM CDI
group by CDI.subj_CDI, hearing_age_CDI_group
ORDER BY CDI.subj_CDI, CDI.hearing_age_CDI ASC) CDI_filtered
on
CDI.subj_CDI = subj_CDI_grouping
AND CDI.hearing_age_CDI = CDI_filtered.min_hearing_age_CDI
where hearing_age_CDI_group is not null
ORDER BY
CDI.subj_CDI, CDI_filtered.hearing_age_CDI_group
END //
我在“End //”处收到语法错误虽然以下两个答案的组合有效,但实际代码本身会引发该错误......