What is unpivot?



What is unpivot?..

Answer / Chandrakant Bharti

UNPIVOT is a SQL operator used to transpose rows into columns. It allows you to convert rows with multiple columns into a single row with multiple identical column names, which can be useful for analyzing data from various dimensions. For example, the following query uses UNPIVOT to transform a table with two columns (Product and Q1-2020, Q2-2020) containing sales data for each quarter:nn SELECT * FROM SalesDatan UNPIVOT(n SalesAmount FOR Quarter IN (Q1-2020 AS Q1,n Q2-2020 AS Q2)n )

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Is it possible for a stored procedure to call itself or recursive stored procedure?

1 Answers  


Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar- 2008,4-feb-2008.Under Employee name 4 difeerent names jaison,robin,binoy,rahul Result set is, Table containing 4-column name=jan,feb,mar,april,,beneath these months count is given as 1,2,1,0 means these counts representing number of emplooyees joined in a month(january 1employee,february 2 employee,march 1 employee,april 0 employee) Can you give me the required sql query

3 Answers   RND Soft, Wipro,


What is microsoft sql server?

1 Answers  


Why I can not enter 0.001 second in date and time literals in ms sql server?

1 Answers  


what is the sql equivaent of the dataset relation object ?

1 Answers  


What is the purpose of object explorer and its features? : sql server management studio

1 Answers  


What factors you will consider calculating the storage requirement for that view?

1 Answers  


Explain how to maintain a fill factor in existing indexes?

1 Answers  


What do we have to check in database testing?

1 Answers  


how to copy only distinct data into another table which is not already exist in database?

2 Answers   Spectra,


What is the diffrence between update_one and auto_fix?

3 Answers   IBM,


How to find the list of fixed hard drive and free space on server?

1 Answers  


Categories