Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need help on a simple query

705455Jun 5 2009 — edited Jun 7 2009
Hello,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2009
Added on Jun 5 2009
9 comments
675 views