Transpose Column to row

create table #temp
(timeId int, dim1Id int, dim2Id int, Value decimal(25,10))

insert into #temp
values
(1, 1, 1, 111)
,(1, 1, 2, 112)
,(1, 2, 1, 121)
,(1, 2, 2, 122)
,(2, 1, 1, 211)
,(2, 1, 2, 212)
,(2, 2, 1, 221)
,(2, 2, 2, 222)


select dim1Id, dim2Id, [1], [2]
from
(select * from #temp) as sourceTable
pivot
(sum(Value) for TimeId in ([1], [2])) as pivotTable



drop table #temp

I want to drink a coffee :-)


Sponsored Links


Ricerca


Ultimi Contenuti Inseriti

How to add onload property to masterpage from child
HtmlGenericControl body = (HtmlGeneric...

C# ASP.NET
...

Transpose Column to row
create table #temp (timeId int, dim1Id int, dim2I...

SQL Server
...

(X) HTML
Suggerimenti ed esempi riguardanti il linguaggio H...

Sponsor