R
ryan.fitzpatrick3
I have a list of item numbers which have all the cost change
transactions next to it, meaning, everytime that item price has gone
up or down its recorded. So an item could look like
# 300365 1/1/2000 $21.00
3/5/2002 $ 22.20
6/8/2003 $ 20.80
2/1/2006 $ 20.50
10/12/2007 $22.20
This would be an example of an item with cost changes with price. I'm
running a query that has date parameters on it, so far this works
fine. What I'm having trouble with is lets say I want to run a query
between 1/1/2006 to 12/31/2006, for a full year, how do I get the
price of $20.50 to reflect instead of $22.20? I'm tried max and last
in the query field which has the pricing, but that just gives me the
max and last price for that item code. Does this make sense? Did I
explain enough? Here is SQL just in case.
SELECT QryPODetailsQuantitySpend.gl_cmp_key,
QryPODetailsQuantitySpend.so_brnch_key,
QryPODetailsQuantitySpend.en_vend_key,
QryPODetailsQuantitySpend.en_vend_name,
QryPODetailsQuantitySpend.in_item_key,
QryPODetailsQuantitySpend.in_desc,
Sum(QryPODetailsQuantitySpend.po_dtl_ordqt) AS SumOfpo_dtl_ordqt,
QryPODetailsQuantitySpend.po_dtl_uom,
Sum(QryPODetailsQuantitySpend.Spend) AS SumOfSpend,
Max(QryVendorPriceFreightSum.LastOfTotal) AS MaxOfLastOfTotal
FROM QryPODetailsQuantitySpend INNER JOIN QryVendorPriceFreightSum ON
(QryPODetailsQuantitySpend.in_desc = QryVendorPriceFreightSum.in_desc)
AND (QryPODetailsQuantitySpend.in_item_key =
QryVendorPriceFreightSum.in_item_key) AND
(QryPODetailsQuantitySpend.en_vend_name =
QryVendorPriceFreightSum.en_vend_name) AND
(QryPODetailsQuantitySpend.en_vend_key =
QryVendorPriceFreightSum.en_vend_key) AND
(QryPODetailsQuantitySpend.so_brnch_key =
QryVendorPriceFreightSum.so_brnch_key) AND
(QryPODetailsQuantitySpend.gl_cmp_key =
QryVendorPriceFreightSum.gl_cmp_key)
GROUP BY QryPODetailsQuantitySpend.gl_cmp_key,
QryPODetailsQuantitySpend.so_brnch_key,
QryPODetailsQuantitySpend.en_vend_key,
QryPODetailsQuantitySpend.en_vend_name,
QryPODetailsQuantitySpend.in_item_key,
QryPODetailsQuantitySpend.in_desc,
QryPODetailsQuantitySpend.po_dtl_uom
HAVING (((QryPODetailsQuantitySpend.in_desc) Like "*" & [Item Name] &
"*"));
LastofTotal is the query field that contains the pricing. Thanks in
advance.
Ryan
transactions next to it, meaning, everytime that item price has gone
up or down its recorded. So an item could look like
# 300365 1/1/2000 $21.00
3/5/2002 $ 22.20
6/8/2003 $ 20.80
2/1/2006 $ 20.50
10/12/2007 $22.20
This would be an example of an item with cost changes with price. I'm
running a query that has date parameters on it, so far this works
fine. What I'm having trouble with is lets say I want to run a query
between 1/1/2006 to 12/31/2006, for a full year, how do I get the
price of $20.50 to reflect instead of $22.20? I'm tried max and last
in the query field which has the pricing, but that just gives me the
max and last price for that item code. Does this make sense? Did I
explain enough? Here is SQL just in case.
SELECT QryPODetailsQuantitySpend.gl_cmp_key,
QryPODetailsQuantitySpend.so_brnch_key,
QryPODetailsQuantitySpend.en_vend_key,
QryPODetailsQuantitySpend.en_vend_name,
QryPODetailsQuantitySpend.in_item_key,
QryPODetailsQuantitySpend.in_desc,
Sum(QryPODetailsQuantitySpend.po_dtl_ordqt) AS SumOfpo_dtl_ordqt,
QryPODetailsQuantitySpend.po_dtl_uom,
Sum(QryPODetailsQuantitySpend.Spend) AS SumOfSpend,
Max(QryVendorPriceFreightSum.LastOfTotal) AS MaxOfLastOfTotal
FROM QryPODetailsQuantitySpend INNER JOIN QryVendorPriceFreightSum ON
(QryPODetailsQuantitySpend.in_desc = QryVendorPriceFreightSum.in_desc)
AND (QryPODetailsQuantitySpend.in_item_key =
QryVendorPriceFreightSum.in_item_key) AND
(QryPODetailsQuantitySpend.en_vend_name =
QryVendorPriceFreightSum.en_vend_name) AND
(QryPODetailsQuantitySpend.en_vend_key =
QryVendorPriceFreightSum.en_vend_key) AND
(QryPODetailsQuantitySpend.so_brnch_key =
QryVendorPriceFreightSum.so_brnch_key) AND
(QryPODetailsQuantitySpend.gl_cmp_key =
QryVendorPriceFreightSum.gl_cmp_key)
GROUP BY QryPODetailsQuantitySpend.gl_cmp_key,
QryPODetailsQuantitySpend.so_brnch_key,
QryPODetailsQuantitySpend.en_vend_key,
QryPODetailsQuantitySpend.en_vend_name,
QryPODetailsQuantitySpend.in_item_key,
QryPODetailsQuantitySpend.in_desc,
QryPODetailsQuantitySpend.po_dtl_uom
HAVING (((QryPODetailsQuantitySpend.in_desc) Like "*" & [Item Name] &
"*"));
LastofTotal is the query field that contains the pricing. Thanks in
advance.
Ryan