SELECT distinct t1.vssyspackageid,CA.rAmount as Amount,Curr.vsShortCode AS Currency
from tblPrograms
INNER JOIN tblProgramsAndPackages ON tblPrograms.vsSysProgramId = tblProgramsAndPackages.vsSysProgramId
inner join tblPackages t1 on tblProgramsAndPackages.iPackageId=t1.iPackageId
right join tblPkgContractAwardDetails as CA on CA.iPackageId=t1.iPackageId
join tblCurrencies as Curr on CA.iCurrency =Curr.iCurrencyId
where tblPrograms.vsSysProgramId='JICA'
group by t1.vssyspackageid,CA.rAmount,Curr.vsShortCode
如果哪个包分配给承包商奖明细则,那么它将显示在一列中。
示例:GWSSP / 01,GWSSP / 02之后它显示下一列中的总包。
答案 0 :(得分:0)
我不确定你想要什么,因为你的问题有点模糊,但我猜你想要一个指定Package的行,它将显示Amount列的总和。无论如何,这是我能从你的问题中理解的!
SELECT DISTINCT t1.vssyspackageid,
SUM(CA.rAmount) AS TotalAmount,
Curr.vsShortCode AS Currency
FROM tblPrograms
INNER JOIN tblProgramsAndPackages ON tblPrograms.vsSysProgramId =
tblProgramsAndPackages.vsSysProgramId
INNER JOIN tblPackages AS t1 ON tblProgramsAndPackages.iPackageId =
t1.iPackageId
RIGHT JOIN tblPkgContractAwardDetails AS CA ON CA.iPackageId =
t1.iPackageId
JOIN tblCurrencies AS Curr ON CA.iCurrency =
Curr.iCurrencyId
WHERE tblPrograms.vsSysProgramId = 'JICA'
AND t1.[YOUR_COLUMN_NAME_HERE] = 'GWSSP/01'
GROUP BY t1.vssyspackageid,
Curr.vsShortCode
只需注意几点:
tblPackages
表中的列名称,例如'GWSSP / 01'所属的值,所以我留给你填写。Curr.vsShortCode
。