From: | "murat akca" <muratakca(at)gmail(dot)com> |
---|---|
To: | "Mustafa Kemal UGURLU" <mustafakemalugurlu(at)gmail(dot)com> |
Cc: | pgsql-tr-genel(at)postgresql(dot)org |
Subject: | Re: Colums to rows transpoze işlemi |
Date: | 2009-01-09 10:21:38 |
Message-ID: | e6ec84b60901090221u4b4c8de8t5e831871c6d5d195@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-tr-genel |
Merhaba,
Pek efektif bir yontem olmasada asagidaki SQL kullanilabilir.
*select isim,donem,field1 from tablo union all (select isim,donem,fields
from tablo) union all (select isim,donem,field3 from tablo)*
Oracle'da unpivot fonksiyonu ile bunu yapmak kolay ama PostgreSQL icin hazir
bir fonksiyon var mi bilemiyorum.
Benim tavsiyem "select * from tablo" ile butun veriyi almak ve uygulama
katmaninda istediginiz gibi duzenlemeniz. Ama illa SQL ile almaniz
gerekiyorsa, efektif bir yontem olmasa da UNION ALL kullanılabilir.
Iyi Calismalar
Murat Akca
2009/1/9 Mustafa Kemal UGURLU <mustafakemalugurlu(at)gmail(dot)com>
> Selamlar,
>
> Elimde aşagıdaki gibi bir tablo var
>
> isim donem field1 field2 field3
> A 200801 1 2 3
> B 200801 2 3 4
> A 200802 3 4 5
> B 200802 4 5 6
>
>
> sorgu sonucunda su sekilde almak istiyorum.
>
> isim donem field value
> A 200801 field1 1
> A 200801 field2 2
> A 200801 field3 3
> B 200801 field1 2
> B 200801 field2 3
> B 200801 field3 4
> A 200802 field1 3
> A 200802 field2 4
> A 200802 field3 5
> B 200802 field1 4
> B 200802 field2 5
> B 200802 field3 6
>
>
>
> contrib içindeki tablefunc ta crostab var ama bu şekilde veriyi almayı
> beceremedim.
> Yukarıdaki dönüşümü nasıl yapabilirim?
>
> Teşekkürler
>
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
From | Date | Subject | |
---|---|---|---|
Next Message | ekren e | 2009-02-02 21:35:02 | pg_version |
Previous Message | Mustafa Kemal UGURLU | 2009-01-09 10:00:52 | Colums to rows transpoze işlemi |