def getDogDetailsTotalExpense(cursor, dog_id):
    """Calculate total expense associated with this dog"""
    query = f"SELECT dogID, sum(amount) as total FROM Expense WHERE dogID ={dog_id} GROUP BY dogID ORDER BY dogID;"
    cursor.execute(query)
    query_result = cursor.fetchall()
    # if we don't have any expense record
    if len(query_result) < 1:
        # total expense should be 0
        total_expense = 0
    else:
        total_expense = query_result[0][1]
    return total_expense