最简单的直接把 as c 这段拿到外面再套一层查询
select t.a,t.b,t.c,(select s.c from table1 s where t.id=s.tid) from (select t.a,t.b,sum(t.sal) as c,max(t.id) as id from table t group by a,b) t