Is it possible to create an SQL join using a data range?

Yes this is possible it is much like any other join in SQL.

We can use the ON key word and then in brackets give a criteria, usually this is primary key = foreign key but in this instance we can use that plus the AND keyword to describe another joining criteria.

Here we can use any SQL command so we could say a.start_date >= sysdate or we could say a.start_date between dateadd(month,-6, sysdate) and sysdate. We could also say a.start_date >= dateadd(month, -6, sysdate) and (a.end_date > systdate or a.end_date is null)

All the above will work to join two tables based on a date range.

By using, you agree to our use of cookies to enhance your experience.