select substr(seq, 1, 2) idid, sum(value) from table group by substr(seq, 1, 2);