select Patient.PatientID, MAX(Cash.CashID) as MaxID,SUM(Cash.Amount) as Balance
from Patient left join Cash
On Patient.PatientID=Cash.PatientID
group by Patient.PatientID
用這個陳述句查詢sql server 2008 在Sql server里可以正確執行,但在Delphi三層里,服務端用FireQuery,客戶端用ClientDataset傳遞這個陳述句過去打開資料集,只有PatientID和maxid能獲得正確的值,balance總為0或空,這是什么原因?
uj5u.com熱心網友回復:
沒有你的這個環境,幫不上忙。uj5u.com熱心網友回復:
select PatientID, MAX(CashID) as MaxID,SUM(Amount) as Balancefrom (
select Patient.PatientID,Cash.CashID,Cash.Amount
from Patient left join Cash
On Patient.PatientID=Cash.PatientID ) A
Group By PatientID
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/87396.html
標籤:數據庫相關
