
March 4th, 2004, 05:43 PM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Problems With Sum...
Hi all,
Ok. Ive want to make a querie that sums values from different tables, for example daily sales(wich are in sales detail table), daily outgoing products(with are in an outgoing detail table) and daily incoming products(wich are in a incoming detail table) *** sorry for outgoing and incoming, dont know if i used the correct terms***. So I do a sum(prod_sales),sum(prod_out),sum(prod_in) grouping them by product id. When i query the tables the answers are completly out of bounds
heres my query:
select Productos.ProdId,sum([detalle facturas].ProdCant) as Ventas,sum([detalle facturas].Boncan) as Bonificaciones,sum([detalle salidas de producto].ProdCant) as Salidas,sum([detalle entradas de producto].ProdCant) as Entradas from facturas,[detalle facturas],[salidas de producto],[detalle salidas de producto],entradas,[detalle entradas de producto],productos
where facturas.facid = [detalle facturas].facid and [salidas de producto].salnum = [detalle salidas de producto].salnum
and entradas.entnum = [detalle entradas de producto].entnum and [detalle facturas].prodid = productos.prodid and
[detalle salidas de producto].prodid = productos.prodid and [detalle entradas de producto].prodid = productos.prodid
Group By Productos.ProdId
Is there any way to make this query work giving me the correct values or do i have to query each table individually.
Any help will be great...
|