SQL Server 基础 之 CASE 子句
SELECT TOP 10 SalesOrderID, SalesOrderID % 10 AS 'Last Digit',-- 求最后一位的值 Position = CASE SalesOrderID % 10 WHEN 1 THEN 'First' WHEN 2 THEN 'Second' WHEN 3 THEN 'Third' WHEN 4 THEN 'Fourth' ELSE 'Something Else' END FROM Sales.SalesOrderHeader