What is pivot Operator ?? Why use Pivot Operator
Microsoft Net Framework

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 

)

Src

Pivot

(

Sum( Income Amount) For IncomeDay In

([January],[Feb],[March]) 

) As PivotTable

 

It Give us Result like This

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

 

Share This with your friend by choosing any social account


Upcoming Articles
You may also read following recent Post
Copyright Future Minutes © 2015- 2024 All Rights Reserved.   Terms of Service  |   Privacy Policy |  Contact US|  Pages|  Whats new?
Update on: Dec 20 2023 05:10 PM