I want to add these two amounts but I get two different rows because they are unequal the amount should give me "2231" and a single row:
MONTO NAC CEDULA CODIGO SUBCODIGO FISCAL FECHA
1673,25 V 8018573 28 50 2017 11/05/17
557,75 V 8018573 28 50 2017 30/05/17
This is the query I'm applying:
SELECT DISTINCT SUM(DETA_MTO_CUOTA) MONTO, DETA_NACIONALIDAD NAC, DETA_CEDULA CEDULA, DETA_CODIGO CODIGO,
DETA_SUB_CODIGO SUBCODIGO, DETA_AJUN_ANO_FISCAL FISCAL, DETA_FEC_CRE FECHA
FROM SRH_DETALLE_AJUS
WHERE DETA_AJUN_NRO = 6351
AND DETA_TIPO_REG = 'A'
AND DETA_SUB_CODIGO = 50
GROUP BY DETA_NACIONALIDAD,DETA_CEDULA,DETA_CODIGO,DETA_SUB_CODIGO,DETA_AJUN_ANO_FISCAL,DETA_FEC_CRE
Even though I am using DISTINCT
or GROUP BY
I can not add and have only one row.
Thank you very much.