I use SQL at work to gather info, but nothing too advanced (yet).
I need to determine patterns of inventory instock and out of stock.
I have a table that shows item, location, inventory and date. I want to see if there is a pattern to the times when an item/location is out of stock and instock over time. The file contains a rolling three weeks of data. If an item is consistently going instock or out of stock in three weeks, then I need to know about it to research further.
An item/location is instock if inventory greater than zero. An item/location is out of stock if inventory is zero or negative.
Thanks for any assistance.
Sample data
Item, location, inventory, date
1243, 10, 2, 3/12/2012
1243, 10, 0, 3/13/2012
1243, 10, -2, 3/14/2012
1243, 10, -2, 3/15/2012
1243, 10, 4, 3/16/2012
Then additional item, location, inventory, date records.
Open to suggestions for output. I just need to see the item/location and how many times it switched between instock and out of stock in the three weeks worth of data.
Something like this may be what you’re looking for. This will count the number of times that each combination of
itemandlocationmoves from “In Stock” to “Out of Stock” or vice versa. Note that the first row for eachitemandlocation, cannot be counted as a transition because we don’t know the prior status given this logic.This shows that the item went from Out of Stock to In Stock once and from In Stock to Out of Stock once in the sample data you posted.