Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
SQL Server 2000/2005/2008, Express, Access, MySQL, Oracle
Pivot
venerdì 17 settembre 2010 - 12.50
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
Elenco Tags
VB.NET
|
SQL Server 2008 R2
memmo77
Profilo
| Expert
683
messaggi | Data Invio:
ven 17 set 2010 - 12:50
Dovrei mettere in pivot questa select
SELECT
FK_ID_mia_tabella
,TC_1
,TC_2
,TC_3
,TC_4
,TC_5
,TC_6
,TC_7
,TC_8
FROM mia_tabella
In sostanza i vari tc sono colonne con dei valori che dovrebbero trasformarsi in righe con i relativi valori
Grazie
lbenaglia
Profilo
| Guru
5.625
messaggi | Data Invio:
ven 17 set 2010 - 14:27
>In sostanza i vari tc sono colonne con dei valori che dovrebbero
>trasformarsi in righe con i relativi valori
Ciao,
Mi sembra di capire che hai bisogno esattamente dell'operatore opposto a PIVOT, ovvero UNPIVOT
In questo thread troverai un esempio completo:
http://www.dotnethell.it/forum/messages.aspx?ThreadID=26582
>Grazie
Prego.
Ciao!
--
Lorenzo Benaglia
Microsoft MVP - SQL Server
http://blogs.dotnethell.it/lorenzo/
memmo77
Profilo
| Expert
683
messaggi | Data Invio:
ven 17 set 2010 - 15:05
hahaha esattamente :P, ho risolto con :
----Create the table and insert values as portrayed in the previous example.
--CREATE TABLE pvt (VendorID int, Emp1 int, Emp2 int,
-- Emp3 int, Emp4 int, Emp5 int);
--GO
--INSERT INTO pvt VALUES (1,4,3,5,4,4);
--INSERT INTO pvt VALUES (2,4,1,5,5,5);
--INSERT INTO pvt VALUES (3,4,3,5,4,4);
--INSERT INTO pvt VALUES (4,4,2,5,5,4);
--INSERT INTO pvt VALUES (5,5,1,5,5,5);
--GO
----Unpivot the table.
--SELECT VendorID, Employee, Orders
--FROM
-- (SELECT VendorID, Emp1, Emp2, Emp3, Emp4, Emp5
-- FROM pvt) p
--UNPIVOT
-- (Orders FOR Employee IN
-- (Emp1, Emp2, Emp3, Emp4, Emp5)
--)AS unpvt;
--GO
Grazie
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !