如果我想在SQL Server 2008中的案例语句的那么语句中使用 if 条件。如何使用它?
答案 0 :(得分:2)
嵌套他们
CASE
WHEN foo = 'bar' THEN
CASE
WHEN black = 'white' THEN ..
WHEN W = 'TF' THEN ...
ELSE
END
WHEN fish = 'bicycle' THEN ...
ELSE ...
END
答案 1 :(得分:1)
您可以在Sql server
中使用Then
关键字Case语句,如下所示
SELECT ProductNumber, Category =
CASE ProductLine
WHEN TestRowValue = 'R' THEN
Case When TestColumn = 'P' THEN 'Road'
ELSE 'Board'
WHEN 'M' THEN 'Mountain'
WHEN 'T' THEN 'Touring'
WHEN 'S' THEN 'Other sale items'
ELSE 'Not for sale'
END,
Name
FROM Production.Product