Home > Back-end >  Records between 2 dates Oracle SQL
Records between 2 dates Oracle SQL

Time:09-22

I am looking to filter out records between 2 dates. Here is a list of start and end dates. I need identify records that fall under the respective periods. I am able to identify the records that fall in the first and last period i.e. first (9/07/2020 - 22/07/2020) and last (10/11/2020 - 23/12/2020) by using MIN and MAX. I am not able to find records that fall in between i.e. 2-11?

enter image description here

I have another table that shows a date when the records were updated. For instance,

enter image description here

I need to identify the records that falls under what periods. For instance,

enter image description here

Any kind of help would be appreciated!

Thanks

CodePudding user response:

You need to do a join on your two tables. You don't give your table names, so this is a bit of guesswork, but try something like this:

select * 
  from period_table p
 inner join record_table r on r.changed_date between p.startdate and p.enddate
  • Related