You can do something like this:
=QUERY(A2:B,"SELECT SUM(B) WHERE B IS NOT NULL PIVOT A")
=SUMIF($A2:A,"=" & C2,$B2:B) // copy this into the adjacent cell
=SUM(FILTER($B2:B,$A2:A=C2)) // copy this into the adjacent cell
See example file I created: Milage per Company
- The first solution is the shortest, because it covers two answers in
the same query. It automatically "grows", when you start adding
different companies. If you add something in column B, without
adding something in column A, the table will get messed up. Add a
company in column A again will return the table to normal.
- The second is the most straightforward of them all.
- The third solution allows for some additional tweaking afterwards