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 |
Different Types of Functions ?
hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.
Which table keeps the locking information?
What are data files?
What is the preferred way to create a clustered and non-clustered index? Which index should you create first the clustered or non-clustered?
What is BCP? When do we use it?
How do I change my passwords (database, LDAP, and so on) without causing an outage?
what is differencial backup?how to work?Anybody explai it?
Give main differences between "Truncate" and "Delete".
Can we make the the chages By Using the Sql if u know any function or process please inform me Actuall result: BRK1 Break 1 Part 1 00:01:00:00 60 BRK1 Break 1 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 BRK2 Break 2 Part 2 00:01:00:00 60 BRK2 Break 2 Part 3 00:01:00:00 60 BRK3 Break 3 Part 1 00:01:00:00 60 BRK3 Break 3 Part 2 00:01:00:00 60 Desired O/P: BRK1 Break 1 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 Part 3 00:01:00:00 60
how to avoid cursors? : Sql server database administration
Does sql server use t sql?