Labels

Friday, December 30, 2011

QUOTENAME


















SELECT   Shelf,
         COUNT(i.ProductID)   AS ProductCount,
         QUOTENAME(min(Name)) + ' - ' + QUOTENAME(max(Name))  AS ProductRange
FROM     Production.ProductInventory i
         INNER JOIN Production.Product p 
           ON i.ProductID = p.ProductID
GROUP BY Shelf
ORDER BY Shelf

Here is the partial result set:

Shelf ProductCount ProductRange
A 81 [Adjustable Race] - [Touring Rear Wheel]
B 36 [Adjustable Race] - [Touring Front Wheel]
C 55 [Chain] - [Thin-Jam Hex Nut 9]
D 50 [Guide Pulley] - [Touring End Caps]
E 85 [Cone-Shaped Race] - [Touring Pedal]
F 59 [Down Tube] - [Stem]
G 96 [Decal 1] - [Thin-Jam Lock Nut 9]

No comments:

Post a Comment