SELECT VendorID, [250] AS Emp1, [251] AS Emp2, [256] AS Emp3, [257] AS Emp4, [260] AS Emp5
FROM
(SELECT PurchaseOrderID, EmployeeID, VendorID
FROM Purchasing.PurchaseOrderHeader) p
PIVOT
(
COUNT (PurchaseOrderID)
FOR EmployeeID IN
( [250], [251], [256], [257], [260] )
) AS pvt
ORDER BY pvt.VendorID;
DB1
料號 檢測項目 規格中值 規格上限 規格下限
A A1 5 3 2
A A2 4 6 1
A A3 3 5 1
B A1 4 6 2
B A2 2 3 1
B A4 5 7 2