Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> You seem to be describing a straight reconciliation between two tables. > My > current means of doing this are programmatically but for the simple case > pure SQL should be doable. The main thing is that you have to distinguish > between "duplicate" records first and then match them up: > > Tabl

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> You seem to be describing a straight reconciliation between two tables. > My > current means of doing this are programmatically but for the simple case > pure SQL should be doable. The main thing is that you have to distinguish > between "duplicate" records first and then match them up: > > Tabl

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> For matching triples (foo, bar, baz) the date in table B shouldnt always > be > after any date in table A, as table B contains complete operations? > Operations in Table B can usually be obtained a day after, when Table A gets the updates. Table B contains the physical date of operation. The date

Re: [SQL] Need help building this query

2012-06-21 Thread Oliver d'Azevedo Christina
If I understand correctly, You have table A with a record for each operation performed, perhaps duplicated. And you have table B with one record for each operation completed, Is my understanding correct? I fail to understand what is the report you are trying to obtain, exactly. For example, T

Re: [SQL] Need help building this query

2012-06-21 Thread Oliver d'Azevedo Christina
For matching triples (foo, bar, baz) the date in table B shouldnt always be after any date in table A, as table B contains complete operations? Best, Oliver - Original Message - From: "Rihad" To: Sent: Thursday, June 21, 2012 6:48 PM Subject: [SQL] Need help building this query

Re: [SQL] Need help building this query

2012-06-21 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Rihad > Sent: Thursday, June 21, 2012 1:49 PM > To: pgsql-sql@postgresql.org > Subject: [SQL] Need help building this query > > Hi, folks. I currently need to join two tables

[SQL] Need help building this query

2012-06-21 Thread Rihad
Hi, folks. I currently need to join two tables that lack primary keys, and columns used to distinguish each record can be duplicated. I need to build statistics over the data in those tables. Consider this: TableA: row 1: foo: 123, bar: 456, baz: 789, amount: 10.99, date_of_op: date row 2: foo