Implemented query for selecting debts and payments of users