$this->db->select('(SELECTSUM(payments.amount)FROMpaymentsWHEREpayments.invoice_id=4')ASamount_paid',