【发布时间】:2021-08-24 01:13:15
【问题描述】:
我正在使用这个查询来检索基于 runId 的最新记录,但是这个查询给出了任何结果。
@Query("select vr1 from VendorResult vr1 left join VendorResult vr2 on (vr1.applicationId = vr2.applicationId "
+ "and vr1.productType=vr2.productType and vr1.runId<vr2.runId) "
+ "where vr1.applicationId=?1 and vr1.overallStatus=?2 and vr2.applicationId is null")
List<VendorResult> getVendorResults(String applicationId,String overallStatus);
也试过了
@Query(value = "select vs from VendorResult vs where vs.applicationId=?1 and vs.overallSatatus=?2 and vs.runId = (select max(v.runId) from VendorResult v where v.applicationId = vs.applicationId)",nativeQuery = true)
List<VendorResult> getVendorResults(String applicationId,String overallStatus);
你能帮帮我吗?
【问题讨论】:
标签: sql oracle spring-boot jpa spring-data-jpa