In case you don't have window function.and use a mysql 5.x version
SELECT
`locid`
, SUM(val1)
, (SELECT val2 FROM table1 WHERE id = MAX(t1.`id`)) val2
, (SELECT val3 FROm table1 WHERE id = MAX(t1.`id`)) val3
FROM table1 t1
GROUP By `locid`
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…