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
What are the types of containers in ssis?
How to get all stored procedures in sql server?
Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?
What is create statement?
How can sql server instances be hidden?
Please explain what is “asynchronous” communication in sql server service broker?
Mention the different authentication modes in sql server.
Tell me about normalization in DBMS.
What are the properties of sub-query?
How to use go command in "sqlcmd"?
what is a transaction? : Sql server database administration
What do you mean by an execution plan?
Does partitioning help performance?
how to trace the traffic hitting a sql server? : Sql server database administration
what are user defined datatypes? : Sql server database administration