Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do this using SQL?
Message
De
24/07/2001 06:40:51
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/07/2001 23:32:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00534225
Message ID:
00534278
Vues:
11
>Hi,
> I am wiritng module to calculate item's cost using FIFO method. Therefore, I need to get all of the latest stock in details which it's qty can "included" in current item's balance qty. For example:
>
>Item A
>Current Stock Balance : 50
>
>Latest StockIn Details
>InvNo ItemNo   Qty   Cost Date
>-------------------------------
>A01   ItemA    10    10   22/07/2001   - Include
>A02   ItemA    10    20   21/07/2001   - Include
>A03   ItemA    10    15   19/07/2001   - Include
>A04   ItemA    10    10   18/07/2001   - Include
>A05   ItemA    10    10   10/07/2001   - Include
>A06   ItemA    10    10   08/07/2001   - Exclude since the total qty exceed 50
>
>
>How to use SQL to get the "included" stock in details for all of the items ??
>
>Thank you

John,
Something like this would work :
Select distinct item, 0 from myTable into array arrQty
Select * from myTable ;
  where Item = lcItem ;
  having GetQty(Item,Qty) <= lnBalance ;
  order by item,InvNo


Function GetQty
Lparameters cItem, nQty
Local RowPos
RowPos = asubscript(arrQty,ascan(arrQty,cItem),1)
arrQty[RowPos,2]=arrQty[RowPos,2]+nQty
Return arrQty[RowPos,2]
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform