Hi TechyV users and forumers!
May I ask you, how is SQL 2005 tabulate data works? Can I create my own tabular data? What is the benefit of this data?
Â
Thank You and Have a Good Day!
Derick Karpoff
How does SQL 2005 tabulate works?
Â
Hello,
Here is an example to show you how to use crosstab queries PIVOT in SQL Server 2005. Â In this example a table is created with 3 columns. Column SalesAss, ColumnFR1 and ColumnFR2.Â
// selects the three columns
SELECT SalesAssis, [FR1] AS FR2, [FR2] AS FR2
// create cross-tab results. The (ps) used to create a temporary table for the query result.Â
FROMÂ
(SELECT SalesAssis, Product, Amount
FROM Sales ) ps
PIVOT
(
// pvt will collect the data from the query
SUM (Amount)
FOR Product IN
( [FR1], [FR2])
) AS pvt
Â
The brackets are necessary so that the pivot treats the name inside the brackets as columns.
Â
I hope this is helpful.
Â