码迷,mamicode.com
首页 > 其他好文 > 详细

CASE WHEN THEN

时间:2019-12-28 13:04:06      阅读:49      评论:0      收藏:0      [点我收藏+]

标签:sys   rom   sel   com   object   lse   comm   case when   ges   

SELECT
(CASE
WHEN News_Data.Type = 1 THEN (SELECT Sys_Department.Name FROM Sys_Department WHERE Sys_Department.Id = News_Data.ObjectId)
WHEN News_Data.Type = 2 THEN (SELECT Basic_Community.Name FROM Basic_Community WHERE Basic_Community.Id = News_Data.ObjectId)
WHEN News_Data.Type = 3 THEN (SELECT Basic_Property.Name FROM Basic_Property WHERE Basic_Property.Id = News_Data.ObjectId)
WHEN News_Data.Type = 4 AND ObjectId != ‘00000000-0000-0000-0000-000000000000‘ THEN (SELECT Basic_HousingEstate.Name FROM Basic_HousingEstate WHERE Basic_HousingEstate.Id = News_Data.ObjectId)
WHEN News_Data.Type = 4 AND ObjectId = ‘00000000-0000-0000-0000-000000000000‘ THEN ‘‘
ELSE ‘‘
END
)ObjectName,*
FROM News_Data WHERE State= 1

CASE WHEN THEN

标签:sys   rom   sel   com   object   lse   comm   case when   ges   

原文地址:https://www.cnblogs.com/JAVA-BK/p/12111207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!