我对 clausule 有疑问SUM
。我需要根据列的总和。
这可能吗?
有没有人有一个例子让我看看?
我的代码如下:
SELECT
PL_MAT AS 'Código',
RA_NOME AS 'Nome',
RJ_DESC AS 'Cargo',
SUM(PL_HORAS) AS 'Atrasos'
--SUM(PL_HORAS) AS 'Hora Extra' -- I need SUM this
FROM SPL020
INNER JOIN SP9020 ON PL_PD = P9_CODIGO AND SP9020.D_E_L_E_T_ <> '*' AND SPL020.D_E_L_E_T_ <> '*'
INNER JOIN SRA020 ON RA_MAT = PL_MAT AND SRA020.D_E_L_E_T_ <> '*' AND RA_FILIAL = PL_FILIAL
INNER JOIN SRJ020 ON RJ_FUNCAO = RA_CODFUNC
WHERE PL_DATA BETWEEN '20120616' AND '20120715'
AND P9_CODIGO IN ('011','421','013','409')
--AND P9_CODIGO IN ('408','007','420','009','015','016','018') -- I need sum this
AND RA_CODFUNC IN ('0408','1204','1233')--AUX COLETA C,MOTORISTA D,MOTORISTA CARRETEIRO
AND RA_SITFOLH NOT IN ('D','A')
AND PL_FILIAL = '05'
GROUP BY PL_MAT,RA_NOME,RA_ADMISSA,RA_CODFUNC,RJ_DESC,P9_DESC, PL_HORAS, P9_CODIGO
ORDER BY RA_NOME