grouping/clustering query - Mailing list pgsql-sql

From David Garamond
Subject grouping/clustering query
Date
Msg-id 7c33d060810212214h5c85b406i49dd9e8d76bec9bd@mail.gmail.com
Whole thread Raw
List pgsql-sql
Dear all,

I have an invoices (inv) table and bank transaction (tx) table.
There's also the payment table which is a many-to-many relation
between the former two tables, because each invoice can be paid by one
or more bank transactions, and each bank transaction can pay for one
or more invoices. Example:

# (invoiceid, txid)
(A, 1)
(A, 3)
(B, 1)
(B, 2)
(C, 5)
(D, 6)
(D, 7)
(E, 8)
(F, 8)

For journalling, I need to group/cluster this together. Is there a SQL
query that can generate this output:

# (journal: invoiceids, txids)
[A,B] , [1,2,3]
[C], [5]
[D], [6,7]
[E,F], [8]

Regards,
dave


pgsql-sql by date:

Previous
From: "Ryan Hansen"
Date:
Subject: Full Text Index Stats
Next
From: Oleg Bartunov
Date:
Subject: Re: Full Text Index Stats