469,890 Members | 1,766 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

select sum() question

hi,

i have a products database and a sales database. i have product id field in
both which relates to a given product.

i would like to have a query who's result tells me the total cost of the
products sold in the given time period.

i am having trouble with the cost price query.

was hoping for something like

select sum(products.costprice),productID from products where any product
with that productID appears in the sales table

can you help?

thanks
Jul 20 '05 #1
1 1125
mike wrote:
hi,

i have a products database and a sales database. i have product id field in
both which relates to a given product.

i would like to have a query who's result tells me the total cost of the
products sold in the given time period.

i am having trouble with the cost price query.

was hoping for something like

select sum(products.costprice),productID from products where any product
with that productID appears in the sales table

can you help?

thanks

select sum(products.costprice) AS costpricetotal, productID from
products,sales where sales.productID = products.productID;

Something like that.

PS sales and products need to be tables in the same database.
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Seguros Catatumbo | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.