-- 设置数据库上下文
USE TSQLFundamentals2008;
GO
SELECT productid,productname,categoryid,
CASE categoryid
WHEN 1 THEN 'Beverages'
WHEN 2 THEN 'Condiments'
WHEN 3 THEN 'Dairy Products'
WHEN 4 THEN 'Confections'
WHEN 5 THEN 'Grains/Cereals'
WHEN 6 THEN 'Meat/Poultry'
WHEN 7 THEN 'Produce'
WHEN 8 THEN 'Seafood'
ELSE 'Unkown Category'
END AS categoryname
FROM Production.Products;