Question : Pivoting Data

I have a dataset that I need to figure out how to pivot on.  SELECT statement is below.  This results in the following result set:

Date       Type        ItemCode
3/3         A                  BNT
3/3         B                  ORG
3/3         C                  ABC
3/4         A                  JPG
3/4         B                  UIN
3/4         C                  JRG
3/5         A                 YRK
3/5         B                  KBC
3/5         C                  RDK
......................

Type       3/3     3/4      3/5
A           BNT    JPG    YRK
B           ORG    UIN     KBC
C           ABC    YRK   RDK
...

I need a solution that takes in a dynamic date range, and does not require me to define the data as a column.  Thanks!
Code Snippet:
1:
2:
3:
4:
SELECT mm.Date, mm.ItemType, mi.ItemCode
FROM MenuMaster mm
INNER JOIN MenuItem mi ON mm.MenuItemID = mi.MenuItemID
WHERE Date BETWEEN '3/1/2008' AND '3/31/2008'
Open in New Window Select All

Answer : Pivoting Data

Here is a good article on the subject:

Pivot table for Microsoft SQL Server
http://www.sqlservercentral.com/articles/Advanced+Querying/pivottableformicrosoftsqlserver/2434/
Random Solutions  
 
programming4us programming4us