SELECT * FROM( SELECT DISTINCT(item_id),balance FROM `stock_activity` ORDER BY(activity_id) DESC ) t1 GROUP BY (item_id)