Hi,
I have a sql view that shows Me all active lots on stock, my problem is that I must distribute the QtyAllowed from the oldest to newest lot Is this possible?
PS: The Qtyallowed Is a globe data no has lot assigned thats wy I have to distribute it.
Thanks in advance
Example :
Original Info :
ItemCode | LotNr| LotDate |QtyIn|QtyOut|QtyAllocated |QtyAvailable| QtyReserved |
Item1 | Lot01| 2018-10-26 | 233 |216 | | 17 | 50
Item1 | Lot02| 2018-10-29 | 163 | 1 | | 162 | 50
Item1 | Lot03| 2018-10-31 | 100 | 16 | | 84 | 50
Item1 | Lot04| 2018-11-27 | 80 | 0 | | 80 | 50
Final Info :
ItemCode | LotNr| LotDate |QtyIn|QtyOut|QtyAllocated |QtyAvailable| QtyReserved |
Item1 | Lot01| 2018-10-26 | 233 |216 | 17 | 0 | 50
Item1 | Lot02| 2018-10-29 | 163 | 1 | 33 | 129 | 50
Item1 | Lot03| 2018-10-31 | 100 | 16 | | 84 | 50
Item1 | Lot04| 2018-11-27 | 80 | 0 | | 80 | 50
My code is this :
SELECT TOP (100) PERCENT ItemCode, LotNr, LotDate, QtyReceived, QtyUsed, QtyReserved, QtyAvailable, QtyAllocated
FROM dbo.ViewVM_LotesActivosFull
ORDER BY ItemCode, LotDate