0
我需要使用SUM來合計我的數據庫中的所有工資。我無法正常工作。這是給我四行的聲明。除「直接薪酬成本」外,其他所有欄目均相同。我如何合計四項直接薪酬成本,以便我可以擁有一條獨特的產品線?需要SUM SQL語句
這裏是我的代碼..
SELECT C.FOS_PROJ_ID_UNQU||'-'||C.FOS_PROJ_ID_STG||'-'||C.FOS_PROJ_ID_ELMT AS "STATE PROJECT ID",
V.VEND_NM AS "VENDOR NAME",
CC.WRKO_NB AS "WORK ORDER NUMBER",
TO_CHAR(CCD.ATHZ_DT, 'MON-DD-YYYY') AS "AUTHORIZATION DATE",
----I need to SUM the following line ----
TO_CHAR((CTD.DCT_SAL_COST_AMT),'$999,999,999.99') AS "DIRECT SALARY COST",
TO_CHAR(CCC.OVHD_COST_AMT,'$999,999,999.99') AS "OVERHEAD COSTS",
TO_CHAR(CTD.DCT_SAL_COST_AMT + CCC.OVHD_COST_AMT,'$999,999,999.99') AS "TOTAL"
FROM DOT1CARO.DT_VEND V, DOT1CARO.DT_CSPJ_CTRC CC, DOT1CARO.DT_CSPJ C, DOT1CARO.DT_CSPJ_CTRC_DTL CCD, DOT1CARO.DT_CSPJ_CTRC_COST CCC, DOT1CARO.DT_CTCST_TASK_DTL CTD
WHERE V.VEND_ID=CC.VEND_ID
AND CC.CSPJ_ID=C.CSPJ_ID
AND CC.CSPJ_CTRC_ID=CCD.CSPJ_CTRC_ID
AND CCD.CSPJ_CTRC_DTL_ID=CCC.CSPJ_CTRC_DTL_ID
AND CCC.CSPJ_CTCST_ID = CTD.CSPJ_CTCST_ID
AND CCD.ATHZ_DT = '14-NOV-2013'
AND V.VEND_NM LIKE 'Ka%
ORDER BY 2;
請提供數據和期望結果的樣本。 –
[壞習慣踢:使用舊式聯接](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins。 aspx) - 舊式*逗號分隔的表*樣式列表已停止使用ANSI - ** 92 ** SQL標準(超過** 20年前**) –