how to change column into row in sql
Answers were Sorted based on User's Feedback
Answer / kapil
With the help of pivot table in sql server 2005 we can do so
Is This Answer Correct ? | 22 Yes | 5 No |
Answer / vishal
with the help of pivoting....
it will solve the problem of grouping also
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
Answer / sai
I agree with this answer..and also we can do the pivot
transaformation in SSIS.
Is This Answer Correct ? | 1 Yes | 4 No |
How we create SQL Server 2005 Reporting Services ? Give me Sample
What is not null constraint?
What do you understand by hotfixes and patches in sql server?
How to access the inserted record of an event?
How can I know what query is executing by by a particural user? (using sp id or any othe way.)
event classes in sql server
What is a data source or ds? : sql server analysis services, ssas
how to count datewise data in sqlserver
4 Answers CarrizalSoft Technologies, IndusInd Bank,
Which database stores information about replication?
how to write test cases for testing databases,especially for testing and writing test cases for stored procedures.any real time database testers.please answer me.
Using the customer, and order table in northwind database, please write a query to produce xml?
What does it mean to invest in the index?