本文主要是介绍mysql中 COALESCE和CASE WHEN的使用以及创建或替换视图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
create or replace view `自理能力评估视图`
as
SELECT
`ehr_zlnlpg`.`ID` AS `ID`,
`ehr_zlnlpg`.`GRID` AS `GRID`,
`ehr_zlnlpg`.`TJID` AS `TJID`,
`ehr_grjbxx`.`Name` AS `姓名`,
`ehr_grjbxx`.`Sex` AS `性别`,
`ehr_grjbxx`.`Cardnum` AS `身份证号`,
`ehr_zlnlpg`.`SCORESUM` AS `总分`,
`ehr_zlnlpg`.`ZrysZL` AS `责任医生`,
`ehr_zlnlpg`.`ZrysZLID` AS `责任医生ID`,
-- CASE WHEN `a`.`upstate` = 0 THEN '失败' WHEN `a`.`upstate` = -1 THEN '未上传' WHEN `a`.`upstate` = 1 OR `a`.`upstate` > 1 THEN '已上传' ELSE '未知状态' END AS `状态`,
COALESCE(`a`.`upstate`, -1) AS `状态`,
`ehr_zlnlpg`.`TijianDate` AS `日期`
FROM
((
`ehr_zlnlpg`
JOIN `ehr_grjbxx` ON ( `ehr_zlnlpg`.`GRID` = `ehr_grjbxx`.`ID` ))
LEFT JOIN (
SELECT
*
FROM
`ehr_ybs_log`
WHERE
`ehr_ybs_log`.`uptype` = 2
) `a` ON ( `a`.`jktjId` = `ehr_zlnlpg`.`TJID` ))
这篇关于mysql中 COALESCE和CASE WHEN的使用以及创建或替换视图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!