Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mathiyazhagan.sekar@gmail
Starting Member
11 Posts |
Posted - 2008-06-02 : 05:08:13
|
| Hi ALL, I am not able to understand the concept of "PIVOT" queries.I am not able get when and how to use this types of query.Help Me.Cheers,MathiIndia. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-02 : 05:11:15
|
PIVOT is used to 1) denormalize a table2) Make CROSSTAB or PIVOT queries E 12°55'05.25"N 56°04'39.16" |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-06-02 : 05:12:02
|
quote: Originally posted by mathiyazhagan.sekar@gmail Hi ALL, I am not able to understand the concept of "PIVOT" queries.I am not able get when and how to use this types of query.Help Me.Cheers,MathiIndia.
Read books online for pivot. Generally we use PIVOT operator for transforming rows into columns i.e., for producing cross tab reports while getting output.To understand the use of PIVOT go through the below exampledeclare @temp table ( id int ,item varchar(500),yearofsale int)insert into @temp values(1,'t.v',2000)insert into @temp values(2,'radio',2000)insert into @temp values(3,'camera',2001)insert into @temp values(4,'mobile',2002)insert into @temp values(5,'car',2003)select * from @temp ------INPUTselect * from (select yearofsale ,id,item from @temp) apivot(count(id) for yearofsale in ([2000],[2001],[2003],[2002]) )b |
 |
|
|
|
|
|
|
|