Sample Header Ad - 728x90

Except command doesn't work in SQL

0 votes
1 answer
1402 views
I am trying to make an except in SQL but it doesnt exclude the data even though they are identical. SELECT A.payment_id, SUM(A.importe_trx) monto_total FROM [dbo].[ABONOS] A WHERE payment_id = '980190391415704' GROUP BY A.payment_id SELECT B.payment_id payment_id, SUM(B.precio_venta) monto_total FROM [dbo].[SALES_VISANET_USD] B WHERE payment_id = '980190391415704' GROUP BY B.payment_id I used that query to get the data and it's the same, but it doesn't exclude it with the EXCEPT command in the middle SELECT A.payment_id, SUM(A.importe_trx) monto_total FROM [dbo].[ABONOS] A WHERE payment_id = '980190391415704' GROUP BY A.payment_id EXCEPT SELECT B.payment_id payment_id, SUM(B.precio_venta) monto_total FROM [dbo].[SALES_VISANET_USD] B WHERE payment_id = '980190391415704' GROUP BY B.payment_id I use "sum" because in one of the tables it has different amounts with the same payment_id, but when adding and grouping them they give the same amount and the same data as the other table.
Asked by Luis C. (1 rep)
Apr 30, 2020, 04:37 PM
Last activity: Apr 30, 2020, 08:28 PM