Answer Posted / samba shiva reddy . m
creating pivot table:
Columns as Rows
below statement will give as it is data
select
PS.Name, P.Color, PIn.Quantity
from Production.Product P
inner join Production.ProductSubcategory PS
on PS.ProductSubcategoryID = P.ProductSubcategoryID
left join Production.ProductInventory PIn
on P.ProductID = PIn.ProductID
This statement will change the columns as rows
select
*
from
(
select
PS.Name, P.Color, PIn.Quantity
from Production.Product P
inner join Production.ProductSubcategory PS
on PS.ProductSubcategoryID = P.ProductSubcategoryID
left join Production.ProductInventory PIn
on P.ProductID = PIn.ProductID
) DataTable
PIVOT
(
SUM(Quantity)
FOR Color
IN (
[Black],[Blue],[Grey],[Multi],[Red],
[Silver],[Silver/Black],[White],[Yellow]
)
) PivotTable
| Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
difference between Clustered index and non clustered index ?
Do you know data definition language, data control language and data manipulation language?
How to convert a unicode strings to non-unicode strings?
How many servers can we create in a single subscription?
What is collation sensitivity?
What is the difference between clustered and a non-clustered index?
What are different replication agents and what's their purpose? : sql server replication
Explain about merge replications?
Do you know what are acid properties of transaction?
What do you mean by an execution plan?
What is an index. What are the types?
How many null values we can have in a unique key field in sql server?
What are the purposes of floor and sign functions?
How do you Implement SSIS Packages in your Project?
How is foreign key related to primary key?