Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select in SQL Server
Message
From
14/06/2004 16:41:15
 
 
To
14/06/2004 16:03:52
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00913605
Message ID:
00913624
Views:
10
Hi Michael

My test tell me that...but i have a field that's DATE, and if i choose that field the sum is done DATE by DATE and not for all records, that the select retrieve. Supose i have this,
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.00
Look...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_ped
Thank's

João Batista
Previous
Reply
Map
View

Click here to load this message in the networking platform