0
我有三個表這樣的 - 醫院,Diagnosstic和Farmacy。求和從SQL視圖所得的值作爲總
醫院
HospitalID int
PatientID int
Due float
Diagnosstic
DaignosticID int
PatientID int
Due float
Farmacy
FarmacyID int
PatientID int
Due float
的patientID柱是峯從病人表
PatientId int
Patient name var
我有查詢,以顯示所有來自不同表的患者的會費和它們求和爲總。
我成功檢索了患者的所有會費,但我如何計算它們?
我的查詢是:
declare @patient int set @patient=1
BEGIN
SELECT
dbo.Master.Name,
dbo.Diagonistic.Due AS DaigiDue,
dbo.Farmacy.Due AS FramaDue,
dbo.Hospital.Due AS HospiDue
FROM dbo.Diagonistic
FULL OUTER JOIN dbo.Master ON dbo.Diagonistic.PatientId = dbo.Master.PatientId
FULL OUTER JOIN dbo.Farmacy ON dbo.Master.PatientId = dbo.Farmacy.PatientId
FULL OUTER JOIN dbo.Hospital ON dbo.Master.PatientId = dbo.Hospital.PatientId
where
dbo.Master.PatientId= @Patient
end
什麼ü通過由於總的意思是...是指三個或inddividual categore(FRAM,HOSP的總和的總和,diag) –