我问了同样的问题,但没有得到最终答案,所以,在这里再试一次。有两种类型的报价,回购利率或最后价格,我想从两个表中选择日期时间最高的回购利率和日期时间最高的最后价格。这是一个答案,我从最初的帖子中得到了帮助,但如果两者都存在,我需要两条记录(回购和最后价格)。任何人都可以通过更改以下查询来提供帮助:非常感谢!
SELECT QuoteObservations.id,
QuoteObservations.value,
QuoteObservations.quotePointId,
max(QuoteObservations.asOfTime) as asOfTime,
QuoteObservations.dataProviderId,
QuotePoints.quoteType
FROM QuoteObservations
INNER JOIN
QuotePoints
ON QuoteObservations.quotePointId = QuotePoints.id
WHERE QuotePoints.quoteType in (1,2)
group by
QuoteObservations.id,
QuoteObservations.value,
QuoteObservations.quotePointId,
QuoteObservations.dataProviderId,
QuotePoints.quoteType;