---
title: "What is PIVOT and UNPIVOT in SQL?"  
description: "What is PIVOT and UNPIVOT in SQL?"  
author: "Sumit Kesarwani"  
published: 2014-08-21  
updated: 2020-09-15  
canonical: https://www.mindstick.com/interview/1966/what-is-pivot-and-unpivot-in-sql  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# What is PIVOT and UNPIVOT in SQL?

A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table.

UNPIVOT table is reverse of PIVOT Table.

## Answers

### Answer by Sumit Kesarwani

A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table.

UNPIVOT table is reverse of PIVOT Table.


---

Original Source: https://www.mindstick.com/interview/1966/what-is-pivot-and-unpivot-in-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
