SELECT PatientReg.P_Id
, PatientReg.PatientName
, PatientReg.Age
, PatientReg.ClinicalProb
, PatientReg.Mobile
, PatientReg.GuardianName
, PatientReg.AdmitTime
, PatientReg.DPatientId
, PatientReg.Relation
, Bed.BedId, Bed.BedNo
, Sum(InTreatment.Total) AS 'InTreatmentTotal'
, Sum(InTreatment.GTotal) AS 'InTreatmentGTotal'
FROM PatientReg
Inner JOIN Bed ON PatientReg.BedId = Bed.BedId
Inner JOIN InTreatment ON PatientReg.P_Id = InTreatment.PatientId
Group By PatientReg.P_Id
, PatientReg.PatientName
, PatientReg.Age
, PatientReg.ClinicalProb
, PatientReg.Mobile
, PatientReg.GuardianName
, PatientReg.AdmitTime
, PatientReg.DPatientId
, PatientReg.Relation
, Bed.BedId, Bed.BedNo