[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 875
  • Last Modified:

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!
0
JameMeck
Asked:
JameMeck
3 Solutions
 
rashmi_vaghelaCommented:
can you explain what exactly you want in some detail
0
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now