SELECT
                inp_patient_admission.*,
                patient_data.title,
                patient_data.fname,
                patient_data.mname,
                patient_data.lname,
                patient_data.sex,
                patient_data.dob,
                inp_ward.name AS ward_name,
                inp_ward.short_name AS ward_short_name,
                inp_beds.number AS bed_number,
                inp_beds.price_per_day,
                billing.fee,
                SUM(billing.fee) AS totalBill
            FROM
                inp_patient_admission
            Left JOIN patient_data ON inp_patient_admission.patient_id = patient_data.id
            Left JOIN inp_ward ON inp_patient_admission.ward_id = inp_ward.id
            left JOIN inp_beds ON inp_patient_admission.bed_id = inp_beds.id
            left JOIN billing ON inp_patient_admission.encounter_id = billing.encounter
            WHERE inp_patient_admission.status='Admitted'
            ORDER BY admission_date desc

I want to  get recoreds from inp_patient_ward_transfer and calculate the bill for each bed and the number of days spent on that particular bed