Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can PIVOT do this ?
Message
De
18/05/2010 09:50:44
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
18/05/2010 07:20:09
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01464982
Message ID:
01465009
Vues:
44
>Given a SQL2008 table structure:
>
>Id, ColumnId, RowId
>1 1 1
>2 1 2
>3 2 1
>4 2 2
>
>How do I convert it to:
>
>Row, Column1 Column2
> 1 1 3
> 2 2 4
>
>In case it's relevant the values are all GUIDS rather than ints and there will be more columns (and, obviously, rows)
>(Sorry about the spacing....)

I think Linq approach is better as I said in my previous message. Using pivot is not appealing because it is simply an expansion of a syntax like:

sum( iif( ColumnID = 1, 1,0) ) as Column1,
sum( iif( ColumnID = 2, 1,0) ) as Column2

It provides typing ease, but doesn't offer performance. Doing the pivoting yourself it is faster.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform