我目前正在使用DBISAM sql编译器。它与ms sql编译器非常相同,唯一的区别是我不能有任何嵌套的连接语句。
以下查询是一个嵌套查询,用于获取最新的贷款记录和费率。我想知道是否有另一种方法可以在没有嵌套的select语句的情况下编写它。
select * from
(select Loan_Id, Max(effectiveDate) as EffectiveDate from InterestTerms
group by Loan_Id) as Y
join InterestTerms as X on Y.Loan_Id = X.Loan_Id and Y.EffectiveDate = X.EffectiveDate
order by Y.Loan_Id
答案 0 :(得分:0)
您可以尝试以下方法:
select
X.*
FROM
InterestTerms AS X
WHERE
X.effectiveDate IN (
select
Max(Y.effectiveDate) as MaxED
from
InterestTerms as Y
WHERE
Y.Loan_Id = X.Loan_Id
)
order by
X.Loan_Id
<强>(修订版)强>