5>
6>
7> CREATE TABLE Orders (
8> OrderID int NOT NULL ,
9> CustomerID nchar (5) NULL ,
10> EmployeeID int NULL ,
11> OrderDate datetime NULL ,
12> RequiredDate datetime NULL ,
13> ShippedDate datetime NULL ,
14> ShipVia int NULL ,
15> Freight money NULL DEFAULT (0),
16> ShipName nvarchar (40) NULL ,
17> ShipAddress nvarchar (60) NULL ,
18> ShipCity nvarchar (15) NULL ,
19> ShipRegion nvarchar (15) NULL ,
20> ShipPostalCode nvarchar (10) NULL ,
21> ShipCountry nvarchar (15) NULL)
22> GO
1>
2>
3> SELECT TOP 10 OrderID, OrderID % 10 AS 'Last Digit', Position =
4> CASE OrderID % 10
5> WHEN 1 THEN 'First'
6> WHEN 2 THEN 'Second'
7> WHEN 3 THEN 'Third'
8> WHEN 4 THEN 'Fourth'
9> ELSE 'Something Else'
10> END
11> FROM Orders
12> GO
OrderID Last Digit Position
----------- ----------- --------------
(0 rows affected)
1>
2> drop table orders;
3> GO