From: | "David Garamond" <davidgaramond(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | grouping/clustering query |
Date: | 2008-10-22 05:14:49 |
Message-ID: | 7c33d060810212214h5c85b406i49dd9e8d76bec9bd@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Oleg Bartunov | 2008-10-23 06:52:12 | Re: Full Text Index Stats |
Previous Message | Ryan Hansen | 2008-10-20 19:32:34 | Full Text Index Stats |