fixed sql queries for charges.py