SELECT PatientName, Age, ClinicalProb, Mobile, GuardianName, AdmitTime, DPatientId,
Relation, BedId, BedNo, InTreatmentTotal, InTreatmentPrice, P_Id,
Sum(Amount) from
(
SELECT 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.Price) AS 'InTreatmentPrice', PatientReg.P_Id,
EarlyPayment.Amount
FROM PatientReg INNER JOIN
Bed ON PatientReg.BedId = Bed.BedId INNER JOIN
InTreatment ON PatientReg.P_Id = InTreatment.PatientId INNER JOIN
EarlyPayment ON PatientReg.P_Id = EarlyPayment.IP_Id
WHERE (PatientReg.P_Id = '15') AND (PatientReg.InOut = 'I')
GROUP BY PatientReg.PatientName, PatientReg.Age, PatientReg.ClinicalProb, PatientReg.Mobile, PatientReg.GuardianName, PatientReg.AdmitTime, PatientReg.DPatientId,
PatientReg.Relation, Bed.BedId, Bed.BedNo, PatientReg.P_Id, EarlyPayment.Amount
) a
group by PatientName, Age, ClinicalProb, Mobile, GuardianName, AdmitTime, DPatientId,
Relation, BedId, BedNo, InTreatmentTotal, InTreatmentPrice, P_Id