select sum() question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mike

    #1

    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.co stprice),produc tID from products where any product
    with that productID appears in the sales table

    can you help?

    thanks


  • Peter King

    #2
    Re: select sum() question

    mike wrote:
    [color=blue]
    > 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.co stprice),produc tID from products where any product
    > with that productID appears in the sales table
    >
    > can you help?
    >
    > thanks
    >
    >[/color]
    select sum(products.co stprice) AS costpricetotal, productID from
    products,sales where sales.productID = products.produc tID;

    Something like that.

    PS sales and products need to be tables in the same database.

    Comment

    Working...