From the Patient left the join Cash
On Patient. PatientID=Cash. PatientID
Group by Patient. PatientID
Use this statement query SQL server 2008 in SQL server can be executed correctly, but in Delphi three layers, the service side with FireQuery, ClientDataset client to deliver the open data set this statement in the past, only PatientID and maxid can obtain the correct value, the balance total of 0 or empty, what reason is this?
CodePudding user response:
Without you the environment, can't help you,CodePudding user response:
The select PatientID, MAX (CashID) as MaxID, SUM (Amount) as the BalanceThe from (
The select Patient PatientID, Cash CashID, Cash. The Amount
From the Patient left the join Cash
On Patient. PatientID=Cash. A PatientID)
Group By PatientID