Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Colums to rows transpoze işlemi



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
>


Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group