1

Topic: Comparing of records in one table on one column

Good afternoon, faced the task. A condition.
There is a table with records and the creation date, each record refers to the intermediate table... I understand difficult, an example:
1:
ID, DOCTYPE, NAME, DOCDATE
And the intermediate table with the link to record, a type:
DOCTYPE, ID, BASEID, where baseid the link to the document.
Documents of different types, question are stored in the table... And how to select records where date of referring documents it is admissible it is equal?
Example,
1 (PR, 1, Bla-bla, 2/20/2018), (2, TR, Bla-bla, 2/21/2018)
Intermediate (PR, 1, 2)

2

Re: Comparing of records in one table on one column

bitocheg;
select *
from intermediate
join 1  on .ID = item ID
join 1  on vol. ID = item BASEID
and vol. DOCDATE = .DOCDATE

3

Re: Comparing of records in one table on one column

by..... wrote:

bitocheg;
select *
from intermediate
join 1  on .ID = item ID
join 1  on vol. ID = item BASEID
and vol. DOCDATE = .DOCDATE

Thanks worked, I simply still very much am not skilled (

4

Re: Comparing of records in one table on one column

bitocheg;
Old kind syntax

select * from "1" t1, "_" t2 where t1.ID=t2.BASEID and t1.DOCDATE=t2.DOCDATE

Or ANSI syntax

select * from "1" t1 join "_" t2 using (DOCDATE) where t1.ID=t2.BASEID

5

Re: Comparing of records in one table on one column

bitocheg;

wrote:

join 1  on .ID = item ID

The given condition worked? Under the description should not, as BASEID - foreign key on ID 1, instead of ID=ID

6

Re: Comparing of records in one table on one column

DKbru wrote:

bitocheg;
it is passed...
The given condition worked? Under the description should not, as BASEID - foreign key on ID 1, instead of ID=ID

Yes worked, as I do not know. smile you correctly understood the description... And at you in an example you compare two tables, and I can, and all documents are stored in one table smile

7

Re: Comparing of records in one table on one column

bitocheg;
Aha I understood you. And that something blunted, did not understand a statement of the problem a little

bitocheg wrote:

And how to select records where date referring documents it is admissible it is equal?

But it is all the same not clear, why passed by..... So wrote.
There it is simple  a condition - comparing of the same table

select * from "1" t1
join "1" tt1 using (ID, DOCDATE)
join "_" t2 on t1.ID=t2.BASEID

Old syntax:

select * from "1" t1, "1" tt1 "_" t2 where t1.ID=tt1.ID and t1.DOCDATE=tt1.DOCDATE and t1.ID=t2.BASEID

Somehow so like.

8

Re: Comparing of records in one table on one column

DKbru wrote:

bitocheg;
Aha I understood you. And that something blunted, did not understand a statement of the problem a little
it is passed...
But it is all the same not clear, why passed by..... So wrote.
There it is simple  a condition - comparing of the same table

select * from "1" t1
join "1" tt1 using (ID, DOCDATE)
join "_" t2 on t1.ID=t2.BASEID

Old syntax:

select * from "1" t1, "1" tt1 "_" t2 where t1.ID=tt1.ID and t1.DOCDATE=tt1.DOCDATE and t1.ID=t2.BASEID

Somehow so like.

Aha and your example worked, many thanks that chewed to the beginner)