A.select * from R where A != 'TOM'
B.select * from R where A like 'TOM_'
C.select * from R where A like '_TOM'
D.select A, sum(B) from R group by A