Need help on a simple query
705455Jun 5 2009 — edited Jun 7 2009Hello,
I have two tables below:
Table A called company, it has company_id and create_date
Table B called DateRange, it has company_id, begin_date and end_date
The date formulas are stored in the begin_date and end_date columns, e.g. sysdate–1 is stored in the begin_date column and sysdate is stored in the end_date column.
Now I need to modify query B, which is currently throwing an error, to retrieve the same data as query A. Can anyone please help? Thanks in advance.
Query A:
Select company_id
From company
Where create_date between sysdate-1 and sysdate
Query B:
Select a.company_id
From company a
Join DateRange b on a.company_id = b.company_id
Where a. create_date between b.begin_date and b.end_date