Answer the question
In order to leave comments, you need to log in
How can I optimize a select query on two dates from a Sqlite DB?
Compiled a query to select the maximum values from two fields with dates, using several related tables:
SELECT mes.measureCommFromTab, p.XMLizmerenije, p.XMLdatetime, p.measureComm_id
FROM `xmlmessagetab` p
INNER JOIN `indexobjectstab` ps
ON ps.keyID = p.indexObjectsTab_id
INNER JOIN `measurecommtab` mes
ON mes.keyID = p.measureComm_id
WHERE ps.indexObject = '55285'
AND p.XMLdatetime = (SELECT max(p.XMLdatetime)
FROM `xmlmessagetab` p
INNER JOIN `indexobjectstab` ps
ON ps.keyID = p.indexObjectsTab_id
WHERE ps.indexObject = '55285' )
AND p.datetimeMess = (SELECT max(p.datetimeMess) FROM `xmlmessagetab` p INNER JOIN `indexobjectstab` ps ON ps.keyID = p.indexObjectsTab_id WHERE ps.indexObject = '55285' )
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question