Re: grouping/clustering query
От | Joe |
---|---|
Тема | Re: grouping/clustering query |
Дата | |
Msg-id | 4900C251.5040005@freedomcircle.net обсуждение исходный текст |
Ответ на | Re: grouping/clustering query (Steve Midgley <science@misuse.org>) |
Ответы |
Re: grouping/clustering query
|
Список | pgsql-sql |
Steve Midgley wrote: >> # (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] > > Hi Dave, > > I'm not following the logic here. A has 1,3 and B has 1,2. So why does > the first line print: > >> [A,B] , [1,2,3] > > What's the rule that tells the query to output this way? Is it that > all of B's values are between A's values? From a purely accounting standpoint, since transaction 1 was applied to both invoices A and B, you need to group the invoices so that you can compare total invoiced against total paid. Joe
В списке pgsql-sql по дате отправления: