فرض کن
جدول Funcontract
1- serial
2-contractno
و جدول FunCash
1- serial
2- contractref
3-Amount
4- Type
موجود است و مثال 1 بااستفاده از یک Drive Table و مثال 2 هم دقیقا خروجی مشابه مثال 1 رو داره
مثال 1
Select Funcontract.Serial , D.Amount
From Funcontract
Inner Join (
Select contractref, Sum(Amount) as Amount
From FunCash
Where Type = 1
Group By contractref
) D on Funcontract.Serial = D.Contractref
مثال 2
Select Funcontract.Serial, Sum(FUNCash.Amount) as Amount
From Funcontract
Inner Join FunCash On Funcontract.Serial = Funcash.Contractref
Where FunCash.Type = 1
Group By FunContract.serial