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 |
diffrence between Cluster Index and non Cluster Index
How to store and query spatial data?
What is CTE in SQL
What are different backups available in sql server?
What is the usage of the sign function?
What is the partitioning method?
1.can we set the more than 1 primary keys for a table? 2.please give me the difference between Cluster Index and non-Clustered Index 3.can we use query like this "Select * from Table1,Table2;"
What is the difference between Stored Procedure , Function and Package, 1. how many blocks in Package and what are they.
What is the exact numeric data type in sql?
What are the advantages of passing name-value pairs as parameters?
What is WITH CHECK OPTION
3 Answers Karur Vysya Bank KVB,
how do you implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql server database administration
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)