Ref Quant date 001 10.00 01-01-2004 001 5.00 02-01-2004 002 30.00 01-01-2004 002 25.00 10-01-2004 what i need is the sum of all '001'...in this case 15, and the sum of all 002 ...in this case 55, Like 001 15.00 002 55.00Look...it work's i expected
select DISTINCT a.c_cod_matpri, sum(a.n_quant) as quant from tbl_gp_MovimentosPedidos a left outer join tbl_empresa b on b.c_codigo='001' left outer join tbl_gp_CodMateriasPrimas c on a.c_cod_matpri = c.c_codigo left outer join tbl_gp_CodKitEmbalagem d on a.c_cod_matpri = d.c_codigo where a.c_ord_pro = 'OP1000' group by a.c_cod_matpri and that not, select DISTINCT a.c_cod_matpri, a.d_data_ped, sum(a.n_quant) as quant from tbl_gp_MovimentosPedidos a left outer join tbl_empresa b on b.c_codigo='001' left outer join tbl_gp_CodMateriasPrimas c on a.c_cod_matpri = c.c_codigo left outer join tbl_gp_CodKitEmbalagem d on a.c_cod_matpri = d.c_codigo where a.c_ord_pro = 'OP1000' group by a.c_cod_matpri, a.d_data_pedThank's