how to change column into row in sql

Answers were Sorted based on User's Feedback



how to change column into row in sql..

Answer / kapil

With the help of pivot table in sql server 2005 we can do so

Is This Answer Correct ?    22 Yes 5 No

how to change column into row in sql..

Answer / vishal

with the help of pivoting....
it will solve the problem of grouping also

Is This Answer Correct ?    0 Yes 0 No

how to change column into row in sql..

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

how to change column into row in sql..

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

Post New Answer

More SQL Server Interview Questions

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ........ in the emp database plz mail the answer @ mak2786@gmail.com

35 Answers   Oracle, Scend, TechInfini,


How can you start sql server in different modes?

0 Answers  


what is unique and xaml nonclustered index

0 Answers  


what's the information that can be stored inside a bit column? : Sql server database administration

0 Answers  


What is not null constraint?

0 Answers  






Can foreign key be duplicate?

0 Answers  


Can group functions be mixed with non-group selection fields in ms sql server?

0 Answers  


What is meant by Active-Passive and Active-Active clustering setup?

0 Answers  


Describe and explain about SQL native client?

0 Answers  


Explain fundamentals of Data ware housing & OLAP?

2 Answers  


What is transaction server explicit transaction?

0 Answers  


What are types of subqueries?

0 Answers  


Categories