有没有更好的方法来运行此查询?

时间:2015-08-07 07:09:41

标签: mysql group-by inner-join

SELECT SQL_NO_CACHE,
    b.SID,
    b.PID,
    a.DateCreated,
    a.Batch,
    b.Mrp
FROM t1 a INNER JOIN
(
    SELECT a.SID, a.PID, Max(a.MRP) AS Mrp
    FROM t1 a
    WHERE SID IN ('14' , '142', '1420')
    GROUP BY a.SID , a.PID
) b
ON a.SID = b.SID AND a.PID = b.PID AND a.Mrp = b.Mrp

0 个答案:

没有答案