ordered by join? ranked aggregate? how to?

From: wstrzalka <wstrzalka(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: ordered by join? ranked aggregate? how to?
Date: 2009-09-14 14:25:33
Message-ID: d7867e26-d5de-4c48-bfac-d6f266b47ec6@l34g2000vba.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

What I need is to join 2 tables

CREATE TABLE master(
id INT4
);

CREATE TABLE slave (
master_id INT4,
rank INT4,
value TEXT);

What I need is to make the query:

SELECT m.id, array_agg(s.value) AS my_problematic_array
FROM master AS m LEFT JOIN slave AS s ON (m.id = s.master_id)
GROUP BY m.id;

return the 'my_problematic_array' in order specified by slave.rank

As you probably can guest I don't have any idea know how to do it :/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Kellerer 2009-09-14 17:00:37 Re: CHECK constraint on multiple tables
Previous Message Mario Splivalo 2009-09-14 14:20:49 Re: CHECK constraint on multiple tables