查询1:
SELECT MAX(START_DATE) AS HIGHEST_DT
FROM T;
查询2:
SELECT
START_DATE AS LOWER_DT
FROM T
WHERE END_DATE = HIGHEST_DT;
我希望得到像
这样的东西START_DATE HIGHEST_DT
答案 0 :(得分:1)
以下是使用Sub-Query
SELECT
START_DATE AS LOWER_DT,END_DATE as HIGHEST_DT
FROM T
WHERE END_DATE = (SELECT MAX(START_DATE) FROM T)
答案 1 :(得分:1)
因此,您似乎有一个表t
,其中包含两列start_date
和end_date
(可能还有更多列);你想找到最近的(最大)start_date,然后找到end_date等于这个max(start_date)
的所有行,对吗?
一种方法是(未经测试,因为您没有提供测试数据):
select start_date as lower_dt, highest_dt
from (select start_date, end_date, max(start_date) over () as highest_dt
from t)
where end_date = highest_dt;