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
When would you use the stored procedures or functions?
What are the advantages of policy management?
Name some of the open source software that you can use in alternative to SSR?
What is the difference between a primary key and a unique key? Are they the same?
How column data types are determined in a view?
Mention the uses of stored procedures.
What are the new data types are introduced in sql 2000?
What is implicit cursors?
What is the bookmark lookup and rid lookup?
Explain cross join or cartesian product in sql?
What are “phantom rows”?
Explain the purpose of indexes?
Can sql server 2016 run on windows 7?
Which joins are sql server default?
What sql server means?