I need a query that will select the closest date.
I have to tables Pricing and InventoryItem.
tblInventoryIte m
InventoryItemID <- Pk
Description
tblPricing
PricingID <- Pk
InventoryItemID
Price
EffectiveDate
I need to select all the current "prices" for each InventoryItem based
on the Pricing's effective date.
select top 1 * from tblPricing join tblInventoryIte m on
tlbPricing.Inve ntoryItemID = tblInventoryIte m.InventoryItem ID
WHERE
tblPricing.Effe ctiveDate <= GetDate()
This does grab the correct price for a single InventoryItem. But I
need this query run for all InventoryItem's . I probably need some
sort of subquery but I can't figure it out....
Thanks....
I have to tables Pricing and InventoryItem.
tblInventoryIte m
InventoryItemID <- Pk
Description
tblPricing
PricingID <- Pk
InventoryItemID
Price
EffectiveDate
I need to select all the current "prices" for each InventoryItem based
on the Pricing's effective date.
select top 1 * from tblPricing join tblInventoryIte m on
tlbPricing.Inve ntoryItemID = tblInventoryIte m.InventoryItem ID
WHERE
tblPricing.Effe ctiveDate <= GetDate()
This does grab the correct price for a single InventoryItem. But I
need this query run for all InventoryItem's . I probably need some
sort of subquery but I can't figure it out....
Thanks....
Comment