From: | Sinan Duman <sinanduman(at)gmail(dot)com> |
---|---|
To: | Recep KIRMIZI <rkirmizi(at)gmail(dot)com> |
Cc: | "pgsql-tr-genel(at)postgresql(dot)org" <pgsql-tr-genel(at)postgresql(dot)org> |
Subject: | Re: array_agg kullanımı |
Date: | 2014-02-25 17:00:22 |
Message-ID: | 87A0A3E9-3A09-49E0-88ED-B2C84F9E29FE@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-tr-genel |
select product_id, array_agg(updated_at::text,',') from ebebek_productupdate group by product_id;
25 Şub 2014 tarihinde 18:44 saatinde, Recep KIRMIZI <rkirmizi(at)gmail(dot)com> şunları yazdı:
> Merhabalar;
> Aşağıda ki gibi bir tablom var,
>
> ebebek=# SELECT * from ebebek_productupdate;
> id | product_id | price | updated_at
> ----+------------+-------+-------------------------------
> 1 | 1 | 20.11 | 2014-02-25 17:33:34.807815+02
> 2 | 1 | 10.11 | 2014-02-25 17:33:41.818229+02
> 3 | 1 | 15.23 | 2014-02-25 17:34:27.762801+02
> 4 | 4 | 22.22 | 2014-02-25 17:34:37.01767+02
> (4 rows)
>
>
> ben bu ürünleri product_id 'ye göre gruplamak ve her bir product_id için tek satır olacak şekilde görmek istiyorum. Yani ilk 3 satır benim için tek satır olmalı.
>
> Amaç ürünün farklı zamanlardaki fiyat güncellemelerini, aynı satırda, tarih ve fiyatları ile birlikte gösterebilmek.
>
> Gruplama işini id 'ye göre yapıyor ama bu bana istediğim sonucu döndürmüyor:
>
> ebebek=# select array_agg(product_id) as pids, price, updated_at from ebebek_productupdate group by id;
> pids | price | updated_at
> ------+-------+-------------------------------
> {1} | 20.11 | 2014-02-25 17:33:34.807815+02
> {1} | 10.11 | 2014-02-25 17:33:41.818229+02
> {1} | 15.23 | 2014-02-25 17:34:27.762801+02
> {4} | 22.22 | 2014-02-25 17:34:37.01767+02
> (4 rows)
>
> ebebek=# select array_agg(product_id) as pids, price, updated_at from ebebek_productupdate group by pids;
> ERROR: aggregates not allowed in GROUP BY clause
> LINE 1: select array_agg(product_id) as pids, price, updated_at from...
>
>
> Vel hasılı aggregate yaptığım sütuna göre gruplamak istiyorum. Zaten aggregate yapmamdaki amaç ta bu. Lakin konuya hakim değilim.
>
> Tavsiyesi olan?
>
>
> --
> Saygılarımla... Recep KIRMIZI
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe ve unsubscribe komutlarn
majordomo(at)postgresql(dot)org
From | Date | Subject | |
---|---|---|---|
Next Message | Recep KIRMIZI | 2014-02-25 17:25:44 | Re: [pgsql-tr-genel] array_agg kullanımı |
Previous Message | Recep KIRMIZI | 2014-02-25 16:44:19 | array_agg kullanımı |