filmov
tv
UNPIVOT in SQL Server

Показать описание
sql server convert columns to rows in a table
sql server transpose columns to rows
unpivot in sql server example
sql server unpivot example
In this video we will discuss UNPIVOT operator in SQL Server.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
PIVOT operator turns ROWS into COLUMNS, where as UNPIVOT turns COLUMNS into ROWS.
We dicussed PIVOT operator in Part 54 of SQL Server tutorial. Please watch Part 54 before proceeding.
Let us understand UNPIVOT with an example. We will use the following tblProductSales table in this demo.
SQL Script to create tblProductSales table
Create Table tblProductSales
(
SalesAgent nvarchar(50),
India int,
US int,
UK int
)
Go
Insert into tblProductSales values ('David', 960, 520, 360)
Insert into tblProductSales values ('John', 970, 540, 800)
Go
Write a query to turn COLUMNS into ROWS.
SELECT SalesAgent, Country, SalesAmount
FROM tblProductSales
UNPIVOT
(
SalesAmount
FOR Country IN (India, US ,UK)
) AS UnpivotExample
Text version of the video
Slides
All SQL Server Text Articles
All SQL Server Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
sql server transpose columns to rows
unpivot in sql server example
sql server unpivot example
In this video we will discuss UNPIVOT operator in SQL Server.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
PIVOT operator turns ROWS into COLUMNS, where as UNPIVOT turns COLUMNS into ROWS.
We dicussed PIVOT operator in Part 54 of SQL Server tutorial. Please watch Part 54 before proceeding.
Let us understand UNPIVOT with an example. We will use the following tblProductSales table in this demo.
SQL Script to create tblProductSales table
Create Table tblProductSales
(
SalesAgent nvarchar(50),
India int,
US int,
UK int
)
Go
Insert into tblProductSales values ('David', 960, 520, 360)
Insert into tblProductSales values ('John', 970, 540, 800)
Go
Write a query to turn COLUMNS into ROWS.
SELECT SalesAgent, Country, SalesAmount
FROM tblProductSales
UNPIVOT
(
SalesAmount
FOR Country IN (India, US ,UK)
) AS UnpivotExample
Text version of the video
Slides
All SQL Server Text Articles
All SQL Server Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
Комментарии