I have the following data:
ItemTable: (as its)
itemid, storeid, descr, OnHandQty
PriceTableas pt)
itemid, price, EffectiveDate
I need to pull all items from the ItemTable and only ONE record from the PriceTable that matches the itemid from the ItemTable. This ONE record has to be the most recent (EffectiveDate). The PriceTable has multiple entries for each itemid (it's a history table).
The end result I'm looking for is as follows:
its.itemid, its.storeid, its.descr, its.onhandqty, pt.price, pt.EffectiveDate
I know this is simple... but I can't seem to get MAX(somedate) to work. I'm either messing up my subqueries or I'm JOINing incorrectly... or grouping incorrectly for that matter. I don't want to post my current code becuase I would like to see clean examples of how to accomplish this.
Thanks.
ItemTable: (as its)
itemid, storeid, descr, OnHandQty
PriceTableas pt)
itemid, price, EffectiveDate
I need to pull all items from the ItemTable and only ONE record from the PriceTable that matches the itemid from the ItemTable. This ONE record has to be the most recent (EffectiveDate). The PriceTable has multiple entries for each itemid (it's a history table).
The end result I'm looking for is as follows:
its.itemid, its.storeid, its.descr, its.onhandqty, pt.price, pt.EffectiveDate
I know this is simple... but I can't seem to get MAX(somedate) to work. I'm either messing up my subqueries or I'm JOINing incorrectly... or grouping incorrectly for that matter. I don't want to post my current code becuase I would like to see clean examples of how to accomplish this.
Thanks.