sql server - SQL: Calculate the number of Days in a Month with no stock -
I can calculate the number of days in a given month, trying to create a query, which Special stock item unavailable (ie: number = 0).
Currently, I have developed a query that can calculate today's date where stock is unavailable, but I am actually trying to calculate, during a month, how many days Stock Quantity = 0. i.e.: Month of January - Item 'A' had no stock on January 5, January 7 and January 20 - This means that the number of days outside stock = 3
Additional details:
Currently, I am on the basis of my query in determining the stock level of the last transaction (i.e .: if, the last transaction However, the amount of stock = 0) then calculate the number of days between the date of transaction and today. Select [Stock Items]. Stockcode, Case When SM ([StockTits] .Qty_On_Hand) = 0 (thenDedifff (Day, GateDate), Max ([transaction]. Transgenadata [transaction] . [Stocklink] where [stock items]. 'Stock exchange' like 'stockcut' like stockcode '% XXX%' and [transaction] .TransactionDate> 31/10/14 [stock items] by group.StockCode
My thoughts There are different types of transactions - one of which is a well received transaction, maybe it is that day It is possible to calculate where the stock volume was zero and a transaction took place and the date was calculated until the baggage was found.
Thoughts?
Thanks.
SELECT COUNT ([stockiits]] .Qty_On_Hand from dbo. [Transaction] INNER JOIN [StockItems] ON [ Transaction]. [Account linked] = [stock items]. [Stocklink] where [stock items] .Qty_On_Hand) = 0
Comments
Post a Comment