Description:
In this example
we explain that how to converting Rows to Columns in SQL Server. Or how to
create PIVOT in SQL Server query to convert rows to column. Or how to create
columns dynamically in SQL Server. Or how to generate column based on other
table in SQL Server. Or SQL Query to convert rows to columns(PIVOT).
So here we demonstrate
that join two table and convert rows to columns in SQL server. Or how to
convert Rows from multiple tables into columns with values in SQL Server.
Below is the
SQL Query to convert rows to column from other table in SQL Server.
SELECT *
FROM
(
select gl.*,
ds.[Dimension Code],ds.[Dimension Value
ID] from [2016_SCHWEITZER_PROD].dbo.[011_SCHWEITZER
MANUFAKTUR_IT$G_L Budget Entry] as gl left join
[2016_SCHWEITZER_PROD].dbo.[011_SCHWEITZER MANUFAKTUR_IT$Dimension Set Entry] as ds on gl.[Dimension Set ID]=ds.[Dimension Set ID]
-- WHERE gl.[Entry
No_] = 786
)as t
PIVOT
(
max([Dimension Value ID])
FOR
[Dimension Code] IN ([1CCT],[2CCR],[3ICO],[4PFC],[5DEP],[6SMX] )
) AS P
0 comments:
Post a Comment