What is pivot Operator ?? Why use Pivot Operator

  By Rizwan Saqib   Posted on March-30-2018   673

MS Sql Server

Pivot is very usefull and important  Operator in SQL Because if we want to convert Rows in Columns  then we use Pivot Operator  and One Column Define Differnt Result set 

For Example

We have table Of Daily Income 

 ID Vendor IncomeDay  
Income Amount
1  Rehman January 200  
2 Adil  Feburary 500  
3 Jameel March 1000  
4 Adil January 900  
5 Jameel January 800  
6 Rehman Feb 2000  
7 Jameel Feb 4000  

We want To change Months Columns in Row In this Situation we Use Pivot operator


Select * From


Select   Vendor, IncomeDay, Income Amount

from  Daily Income 





Sum( Income Amount) For IncomeDay In


) As PivotTable


It Give us Result like This

Vendor January Feb March
Rehman 200 2000 Null
Adil 900 500 Null
Jameel 900 4000 1000


By  Rizwansaqib966    30-Mar-2018 Views  673

You may also read following recent Post

Submit Post - Article - Ask a Question - Ask an Interview Question - Submit Useful Links