Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个这样的记录列表
ID---EffectiveDate---Rate 1----1/1/2011--------1.2 2----1/1/2012--------1.3 3----1/1/2013--------1.5 4----1/1/2014--------1.2
给定一个日期参数 d1,我想获取 d1 之前的最新生效日期的记录。所以,如果 d1 = 6/1/2012,我想获得第二条记录。如何在 MS Access SQL 中编写这样的查询?
尝试这个,
select top 1 * from tablename where EffectiveDate<=d1 order by EffectiveDate desc
根据您的数据,我认为 SQL 查询看起来像这样:
SELECT TOP 1 EffectiveDate FROM MyTableOfDates WHERE EffectiveDate <= #MyInputDate# ORDER BY EffectiveDate DESC