cómo agrupar y seleccionar de dos tablas, necesita dos loggings para cada identificación dada

Soy nuevo en la consulta SQL. ¿Puedes ayudarme con lo siguiente?

table 1 QuoteObservations:

id value quotePointId asOfTime 

tabla 2 QuotePoints:

 id, quotoType 

quoteType podría ser LastPrice, RepoRate, etc.

Necesito seleccionar id y valor, comoOfTime, quoteType, con el más alto asOfTime de la tabla 1 con quoteType = LastPrice (= 1) o RepoRate (= 2) en la tabla 2; Necesito devolver dos loggings, uno para el último precio, uno para la tasa de recompra para cada identificación, pero tanto el último precio como la tasa de recompra deben ser los más altos en el momento de la llegada.

Tengo esto, pero le da el último precio o la tasa de recompra, el que tenga el valor más alto en function de la hora.

 SELECT QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId, max(QuoteObservations.asOfTime) as asOfTime, QuoteObservations.dataProviderId, QuotePoints.quoteType FROM QuoteObservations, QuotePoints WHERE (QuoteObservations.id =1 OR QuoteObservations.id = 2 ) AND QuoteObservations.quotePointId = QuotePoints.id AND (QuotePoints.quoteType = 1 or QuotePoints.quoteType = 2) group by QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId,QuoteObservations.dataProviderId, QuotePoints.quoteType; 

QuoteObservations.id =1 OR QuoteObservations.id = 2 eliminar la condición WHERE que limita los resultados en QuoteObservations.id =1 OR QuoteObservations.id = 2

Aquí está el SQL revisado, con esa condición eliminada. También moví la condición JOIN a la cláusula JOIN.

 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; 
 SELECT QuoteObservations.id, QuoteObservations.value, QuoteObservations.asOfTime, QuotePoints.quoteType FROM QuoteObservations LEFT JOIN QuotePoints ON QuoteObservations.quotePointId = QuotePoints.id WHERE QuotePoints.quoteType = 1 OR QuotePoints.quoteType = 2 ORDER BY QuoteObservations.asOfTime DESC LIMIT 1; 

Arreglé esta consulta, funciona, pero apuesto a que hay una forma mejor y más eficiente de hacerlo, ¿puede alguien por ahí ayudar?

 select q.* from ( select QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId, max(QuoteObservations.asOfTime) as asOfTime, QuoteObservations.dataProviderId, qp.quoteType from [QuoteObservations] inner join QuotePoints qp on qp.id = QuoteObservations.quotePointId where quotePointId = 1 group by QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId, QuoteObservations.dataProviderId ) q inner join ( select QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId, max(QuoteObservations.asOfTime) as asOfTime, QuoteObservations.dataProviderId, qp.quoteType from [QuoteObservations] inner join QuotePoints qp on qp.id = QuoteObservations.quotePointId where quotePointId = 2 group by QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId, QuoteObservations.dataProviderId ) p on q.id = p.id inner join ( select QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId, max(QuoteObservations.asOfTime) as asOfTime, QuoteObservations.dataProviderId, qp.quoteType from [QuoteObservations] inner join QuotePoints qp on qp.id = QuoteObservations.quotePointId where quotePointId = 10 group by QuoteObservations.id, QuoteObservations.value, QuoteObservations.quotePointId, QuoteObservations.dataProviderId ) s on s.id = p.id