sql server,case语句问题2014

时间:2017-04-29 17:20:32

标签: sql-server case

如何修复我在下面的查询中遇到的语法错误?

SELECT 
    SUBSTRING (A. columnname 2,3) Alias
     ,SUBSTRING(A.columnname, 7,10) Alias2 
FROM Tablename A
left join Tablename B on B.YR = 2017
AND A.columnname = SUBSTRING(b.Columnname 2,3) 
CASE 
WHEN B.columnname = 5 THEN  5
WHEN A.columnname <>'NA' THEN SUBSTRING(B. Columnname 2,3)
END AS First_Quater
INTO ##Results2017
GROUP BY SUBSTRING (A. columnname 2,3) Alias,
SUBSTRING(A.columnname, 7,10) Alias2,First Quater

0 个答案:

没有答案