array_agg kullanımı

From: Recep KIRMIZI <rkirmizi(at)gmail(dot)com>
To: "pgsql-tr-genel(at)postgresql(dot)org" <pgsql-tr-genel(at)postgresql(dot)org>
Subject: array_agg kullanımı
Date: 2014-02-25 16:44:19
Message-ID: CAHxsdf5rS1Nq1JurtfvLP0WfwD71j5QWV61QPa1N+5CikOhmVw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-tr-genel

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

Responses

Browse pgsql-tr-genel by date

  From Date Subject
Next Message Sinan Duman 2014-02-25 17:00:22 Re: array_agg kullanımı
Previous Message Devrim GÜNDÜZ 2013-11-13 13:07:25 4 günlük PostgreSQL eğitimleri