SELECT MAX(f_orderInteractionID)
FROM tOrders O
INNER JOIN tOrderInteractions OI ON OI.fk_orderID = O.f_orderID
GROUP BY OI.fk_orderID
有没有办法替换max函数,因为在实际执行计划中它使用了Index扫描,我更喜欢使用Index seek。如何改进此查询
答案 0 :(得分:0)
要执行此操作,请重试
SELECT f_orderInteractionID
FROM tOrders O
INNER JOIN tOrderInteractions OI ON OI.fk_orderID = O.f_orderID
ORDER BY f_orderInteractionID DESC
LIMIT 1