Is the database in development or is it something that already exists that you have to work with? There are options at going at this but a few more parameters would help in getting an idea of how to go about it. At both mileage and fuel purchase in the same table? Is there any sort of primary key were dealing with here? Are dates listed?
If they were all in the same table and you have no choice but to work with what you have, this could be tricky. If you are looking to develop this correctly in the first place then you have alot more options and this should be fairly easy.
Post a bit more and I will see what I can do to help.