Microsoft introduces new operators PIVOT and UNPIVOT in SQL Server 2005. Traditionally we create queries using the CASE statement and aggregate function in order to produce cross-tab reports. This article illustrates the usage of the new operators, PIVOT and UNPIVOT. Let us assume that we have a table as described below. Create table #MyTable (yearofJoining int, EmpId int, Deptid int) go insert into #MyTable select 1990,1,1 insert into #MyTable select 1991,2,2 insert into #MyTable select 1990,3,4 insert into #MyTable select 1991,4,2 insert into #MyTable select 1990,5,1 insert into #MyTable select 1990,6,3 insert into #MyTable select 1992,7,3 insert into #MyTable select 1990,8,4 insert into #MyTable select 1993,9,1 insert into #MyTable select 1994,10,2 insert into #MyTable select 1990,11,3 insert into #MyTable select 1995,12,3 insert into #MyTable select 1995,14,3 insert into #MyTable select 1995,15,3 insert into #MyTable select 1995,16,6 go In order to create a cross tab report, we ...