首页 > 解决方案 > Getting Table Results based on a Start and End Date using a single date

问题描述

Currently I am having trouble trying to query a data set that contains multiple records for unique customers. Each row has a start date and end date and the most recent record marked as Most Current and end date as 12/31/9999. I am trying to write a query so that I can return all records that fall on a specific date such as months end (10/31/2018). My goal in Oracle SQL Developer is to type in all records/data on the day 10/31/2017 so the rows with the * are the only ones Id want back. The final outcome is to do this with a much larger file and see the entire year at months end where each person was at based on the month end date for 1 year.

Example Data

标签: sqloracledatepoint-in-time

解决方案


我认为您想列出截至指定日期的所有最新记录。为此,我只需使用 BETWEEN 条件:

select * from mytable
where date'2017-31-10' between start and end

推荐阅读