-1
您好我正在处理涉及必须使用CASE的查询。我不断收到错误,但无法弄清楚原因。以下是我所尝试过的。T-SQL中的SQL Server CASE语句
SELECT
CASE
when LineItem like '%Apple%' THEN ProductType = 'Apple'
when LineItem like '%Orange' THEN ProductType = 'Orange'
when LineItem like '%Strawberry' THEN ProductType = 'Red'
when ProductType like 'Yellow' THEN ProductType
else ProductType = 'White'
end as ProductType
FROM Fruits
我得到的错误是在“=”符号上。 在T-SQL中的WHEN关键字之后不可能有两个不同的列吗?
摆脱'ProductType ='的。请使用'ELSE'White'' – BJones
请记住'ProductType like'Yellow''充当'=' –