Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

using a calculation done in the previous row in this row's calculation - response (2) by tbenard

$
0
0

Thanks Dieter.  I am always amazed at how quickly and accurately you guys answer posts. 
Unfortunately, I have one more wrinkle... this works fine, but basically I need this inventory to reset with each new item-location combination. 
I have the data ordered by item-location-week.  On the first week for every item location, I calculate inventory for that row a little differently, then I want to do the sum for the remaining weeks of that item-location week.  This works fine for the first item-location, but then on the second item-location I calculate the first week, but the sum just continues from the previous item location.
case when CUST_WEEK = POS.POSMINWK
then -- first week
ZEROIFNULL(WHS_OH_QTY) + ZEROIFNULL(STORE_OH_QTY) + ZEROIFNULL(CUST_DEMAND_FCST)
+ ZEROIFNULL(SHIP_UNSHIP) - ZEROIFNULL(CUST_POS_FCST)
else -- not the first week
SUM(ZEROIFNULL(WHS_OH_QTY) + ZEROIFNULL(STORE_OH_QTY) + ZEROIFNULL(CUST_DEMAND_FCST)
+ ZEROIFNULL(SHIP_UNSHIP) - ZEROIFNULL(CUST_POS_FCST))
OVER (ORDER BY PUBLISH_DATE,CUST_ITEM,CUST_WHS,CUST_WEEK ROWS UNBOUNDED PRECEDING)
end
as PROJ_INV


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>