List:General Discussion« Previous MessageNext Message »
From:Velen Vydelingum Date:July 16 2011 7:15am
Subject:Query
View as plain text  
Hi,

I have 2 tables:
Sales> Code, Price, sDate
History>Code, Cost, hDate

The sales record sales for each product by its code.  The History table has the cost
history of each product at different date.

I need to know the last cost of each product in the sales table at the date of the sales.

Can anyone help me with the query?

It should be something like : select a.code,a.price,b.cost,a.sDate from sales a, history b
where a.code=b.code and b.hdate<a.sdate

Thanks.

Vel

Thread
QueryVelen Vydelingum16 Jul