Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 FIFO Method

Author  Topic 

Pieter
Starting Member

5 Posts

Posted - 2007-07-08 : 23:53:08
Dear guys,

Sory for bad my english languages.
I have a case in accounting like this below
Result 1:
PartNo Qty InvDate
A 2 16/03/2007
A 2 17/03/2007
A 5 18/03/2007

If user pick PartNo A=3, so my t-sql want to need result like this below :

Result 2:
PartNo Qty InvDate
A 2 16/03/2007
A 1 17/03/2007

Like that, I have a scenario FIFO method. First, pick from InvDate smaller date from other InvDate.

I have a syntax sql to detected the result that ( result 2 ), but i'm still confusing when user pick other PartNo. If user want to pick PartNo=4, so the result should be like this :

Result 3:
Result 3:
PartNo Qty InvDate
A 1 17/03/2007 ==> Because in InvDate A still 1 Qty remaining ( 2-1 ) still 1
A 3 18/03/2007 ==> Because in InvDate A still 5 Qty remaining ( 5-3 ) still 2

And the scenario continues result. So, In InvDate=18/03/2007, A still have remaining Qty=2, because
3 have been pick from result 3.

So, in like that scenario, how i can implement this t-sql method?

Please advise me.I have need more deep learning from this forums,
This forum more good learning like me(beginner) ;-).

need help you guys.Especially from Peso.

Best Regards,


Pieter
Starting Member


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-09 : 00:17:47
Duplicate thread http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86100


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -