SQL FIFO Algorithm

I got stuck with a request like this:

Table 1: Input
ID(Identity)           Number           Weight            Kg/Bar(Weight/Number)
1                           2                       20                     10                        
2                           3                       45                      15
3                           5                       50                      10

Table 2: Output
Number                    Weight
  4                               50 (= 10*2 + 15*2)
  6                               65 (= 15*1 + 10*5)

Please help me how to sovle this problem.
Thanks!
JameMeckAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rashmi_vaghelaCommented:
can you explain what exactly you want in some detail
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dervishiCommented:
can you describe the problem in more details, because I can't understand the question?
0
Chris MConsulting - Technology ServicesCommented:
JameMech, please tell us what is puzzling you so that it gets resolved.

In case you're using ID to trace what comes in first, ensure that your query has an "order by ID asc" clause.
NB: For an identity column, the seed and increment define the pattern of populating the column.

Assuming the column was created with properties like IDENTITY(1:1) then the order by clause to trace first in first out will be ID ASC and the lower IDs will be the first ones to get returned.
0
JameMeckAuthor Commented:
Thanks! I solved by myself.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.