The customer proposes the requirements of printing costs. The problem to be solved is that the drug fees and disposal are not in a table, and the name of the field is not the same, and there are many ways to work. The first thing I think is the sub-report function of the crystal report. Later I gave up. Because it is more troublesome. So I made a joint inquiry: Alter View N_iHbillasselect Cast (Ihformula.inPatientno As Varchar) AS Hospitalization number, I.Name AS Name, I.AGE Age, I.SEX AS Gender, I.DEPT AS Department, m. MName AS project name, IHFormula.Quantity quantity AS, IHFormula.tcost AS amount, n_MedClass.type AS category, IHFormula.FormulaTime AS date FROM IHFormula LEFT OUTER JOIN Medicine m ON m.MediNo = IHFormula.MediNo LEFT OUTER JOIN ihpatientlist i ON IHFormula .InPatientNo = i.InPatientNo LEFT OUTER JOIN n_MedClass ON m.MedClass = n_MedClass.MedClassWHERE IHFormula.flgpay> 0UNION ALLSELECT CAST (i.InPatientNo AS varchar) AS hospital number, i.Name AS name, i.Age AS ages, i. sex AS gender, i.Dept AS departments, Payprice.Treat AS project name, NULL number AS, IHTreat.TCost AS amount, Receipt_Item.Class AS category, IHTreat.TreatTime AS date FROM ihpatientlist i INNER JOIN IHTreat INNER JOIN Payprice ON IHTreat. TRNO = payprice.trno on I.inpatientno = htreat.inpatientno inner join receipt_item on payprice.trclsno = receipt_item.clsno This is EASY.