How can I get this join?

  • How can I get this join?

    Hi

    Excuse me. I can’t speak English well.

    I have 2 tables in my db.

    Master_table has these fields : product_name, receive_date, price.

    Detail table (daily information) has these fields : product_name, sell_date.

    I wants to get a report of products have been selled .

    Since the price of a product is different in some days, the search sql command must use related record in Master_table which the date in master table be related to date in detail table.

    I can do this in ACCESS by use of word “first” . but in SQL SERVER I can’t.

    how is it possible?

    Thanks very much

  • Now the following query gives you the list of products sold along with their selling price on that day.

    select details.product_name,details.sell_date,master.price from master

    inner join details on master.product_name=details.product_name

    and master.receive_date=details.sell_date

    Tip: Try adding a field productID to identify each product uniquely and change the above join based on productID instead of product_name.

  • That way clear enough english... 😉

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply