第一个MYSQL查询
-- selects the latest records by unique member_id
SELECT * FROM table t
JOIN (SELECT MAX( id ) AS id
FROM table
GROUP BY member_id) t2 ON t2.id = t.id
WHERE `t`.`timestamp` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
ORDER BY t.id DESC
LIMIT 10
第二。
-- sums the item_qt column by unique member_id
SELECT SUM(item_qt) AS sum_item_qt FROM table t
WHERE `t`.`timestamp` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
GROUP BY member_id
ORDER BY t.id DESC
LIMIT 10
有没有办法结合这两个查询,以便 sum_item_qt 加入 member_id 的?