Author |
Topic |
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2010-11-23 : 04:24:27
|
Hi All,I have a report to show based on the FIFO method for inventory.Below is the sample dataID Type Value1 IN 24502 IN 46253 IN 14854 OUT 20005 OUT 30006 IN 1250 and desired output isID Type Value PrevBalance UsedOutID UsedQty Balance1 in 2450 0 4 2000 4501 in 450 450 5 450 02 in 4625 0 5 2550 20753 in 1485 2075 0 0 35606 in 1250 3560 0 0 4810 feel free to ask any doubts...Thanks in advance"There is only one difference between a dream and an aim.A dream requires soundless sleep to see,whereas an aim requires sleepless efforts to achieve..!!" |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-11-23 : 04:50:08
|
The Type in last record (#6), is that supposed to be "IN" instead of "INT"? If not then what does it mean?- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2010-11-23 : 04:57:43
|
sorry typo mistake, corrected now.quote: Originally posted by Lumbago The Type in last record (#6), is that supposed to be "IN" instead of "INT"? If not then what does it mean?- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com
"There is only one difference between a dream and an aim.A dream requires soundless sleep to see,whereas an aim requires sleepless efforts to achieve..!!" |
 |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-11-23 : 04:59:20
|
Will the tpe in the output ever be anything other than IN?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2010-11-23 : 05:00:32
|
it will contain only "IN" and "OUT" nothing else.quote: Originally posted by nigelrivett Will the tpe in the output ever be anything other than IN?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
"There is only one difference between a dream and an aim.A dream requires soundless sleep to see,whereas an aim requires sleepless efforts to achieve..!!" |
 |
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-11-23 : 08:49:03
|
If I could make a suggestion to the table structure...I would include the IN record ID for each OUT record. That way you know where it came from. Yes, I understand FIFO rules should make that unnecessary, but it makes it a lot easier when you have to span multiple INs on one OUT, and when you start dealing with multiple products, locations, etc.Plus, makes reporting a far sight easier, as well as returns. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-11-23 : 09:27:48
|
Is this a correct interpretation?ID Type Value1 IN 24502 IN 46253 IN 14854 OUT 20005 OUT 30006 IN 1250 IN OUT1 *--------* 4 *--------* | | | | | | | | | | | | | | *--------* | | 5 *--------* *--------* | |2 *--------* | | | | | | | | | | | | | | | | | | | | *--------* | | | | | | | | *--------*3 *--------* | | | | | | *--------*6 *--------* | | | | *--------*InID Value OutID UsedQty PrevBalance Balance1 2450 4 2000 0 4501 2450 5 450 450 02 4625 5 2550 0 20753 1485 2075 35606 1250 3560 4810 N 56°04'39.26"E 12°55'05.63" |
 |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-11-23 : 09:40:23
|
I spent a good part of my day trying to figure this one out but gave in after not being able to get my head around it. Most of it looks correct according to the specifications but as far as I can see the Value is off...- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2010-11-24 : 05:34:10
|
Hi Peso, U r interpretation of the problem is Correct. The link given by u only gives the final balance not the detail report as in my requirement.quote: Originally posted by Peso Is this a correct interpretation?ID Type Value1 IN 24502 IN 46253 IN 14854 OUT 20005 OUT 30006 IN 1250 IN OUT1 *--------* 4 *--------* | | | | | | | | | | | | | | *--------* | | 5 *--------* *--------* | |2 *--------* | | | | | | | | | | | | | | | | | | | | *--------* | | | | | | | | *--------*3 *--------* | | | | | | *--------*6 *--------* | | | | *--------*InID Value OutID UsedQty PrevBalance Balance1 2450 4 2000 0 4501 2450 5 450 450 02 4625 5 2550 0 20753 1485 2075 35606 1250 3560 4810 N 56°04'39.26"E 12°55'05.63"
"There is only one difference between a dream and an aim.A dream requires soundless sleep to see,whereas an aim requires sleepless efforts to achieve..!!" |
 |
|
|