SQL Server]关键字 'CASE' 附近有语法错误
SELECT
(select count(*) from hocm_project where work_status='在建' and org_id in (
SELECT id from sys_org where parent_id ='16b2a96f9b04428f8f9aca3b04b947e0' ))
AS constructionProject, -在建项目
sum(CASE LEFT(CONVERT(VARCHAR,start_date,23),4) WHEN DateName(year,GetDate()) THEN 1 ELSE 0 END)
AS startThisYear, -今年开工
sum(CASE LEFT(CONVERT(VARCHAR,end_date,23),4) WHEN DateName(year,GetDate()) THEN 1 ELSE 0 END)
AS endThisYear, -今年完工
sum(CASE LEFT(RIGHT(CONVERT(VARCHAR,start_date,23),5),2) WHEN DateName(month,GetDate()) THEN 1 ELSE 0 END)
AS startThisMonth, -本月新增
sum(CASE LEFT(CONVERT(VARCHAR,end_date,23),7) WHEN LEFT(CONVERT(VARCHAR,GetDate(),23),7) THEN 1 ELSE 0 END)
AS endThisMonth, -本月完工
count(*) as projectCount -项目总数
from hocm_project AS pro
e org_id in (
SELECT id from sys_org where parent_id = '16b2a96f9b04428f8f9aca3b04b947e0'
)