Re: Query with 2 x subquery
I'm not clear on what you are doing, but maybe this:
SELECT c1.varid, c1.val, c1.sessionid
FROM data_i16 AS c1
JOIN
( SELECT varid, MAX(sessionid) AS sessionid
FROM data_i16
WHERE partid = '5'
AND sessionid < 1611659
GROUP BY varid
) AS c2 USING (varid, sessionid)
WHERE partid = '5'
AND sessionid < 1611659
ORDER BY c1.sessionid DESC;
data_i16 will need INDEX(varid, sessionid) and INDEX(partid, sessionid).
That's "groupwise max" with an added restraing of WHERE partid = '5' AND sessionid < 1611659
http://mysql.rjweb.org/doc.php/groupwise_max
Subject
Views
Written By
Posted
1726
April 29, 2016 06:44AM
903
April 29, 2016 08:01AM
Re: Query with 2 x subquery
902
May 01, 2016 11:58PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.