我如何在where语句中最好地捕获最新的开始和结束日期(第2行)?
START_DATE END_DATE
1 - 1/1/2017 9/30/2017
2- 10/1/2017 12/31/2017
Where start_date <= '2017-12-31' and end_date >= '2017-01-01'
答案 0 :(得分:0)
您需要order by
子句而不是where
子句:
select top 1 . . .
from . .
order by start_date desc;