-1

I have a BOM to sort as shown in the attached picture and I cannot seem to be able to sort mulitlevel in SQL. in this list Child can be parent. Position seems to be a good way but look at Poition 3. there are two of them when the level changes. (Could if be wrong Join?) Level is the level of the item. it is consistent. I would appreciate if someone can assist.


Wrong (unsorted) table

itemSpecID  +  ParentID  +  ChildID  +  Position  +  Level  +  ItemSpecStrucID  +  ItemNo         +
151382      +  151382    +  150776   +  17        +  1      +  469912           +  FOAM-KIT-00595 +
151382      +  151382    +  151383   +  0         +  1      +  469908           +  CHAR-FRM-00708 +
151382      +  151383    +  151372   +  2         +  2      +  469916           +  HDWR-MIS-00024
151382      +  151383    +  151373   +  3         +  2      +  469917           +  HDWR-MIS-00025
151382      +  151383    +  151374   +  4         +  2      +  469918           +  HDWR-MIS-00026
151382      +  151383    +  151384   +  1         +  2      +  469915           +  HDWR-MIS-00023
151382      +  151382    +  151344   +  4         +  1      +  469910           +  SRVC-GEN-00014
151382      +  151382    +  149441   +  5         +  1      +  469911           +  PANL-BAK-00284
151382      +  151382    +  149079   +  3         +  1      +  469909           +  PANL-SAT-00300
151382      +  151382    +  150765   +  18        +  1      +  469913           +  HDWR-BRK-00015
151382      +  151382    +  150810   +  20        +  1      +  469914           +  FABR-DOUX-00004

Final Sorting needed

itemSpecID  +  ParentID  +  ChildID  +  Position  +  Level  +  ItemSpecStrucID  +  ItemNo
151382      +  151382    +  151383   +  0         +  1      +  469908           +  CHAR-FRM-00708
151382      +  151383    +  151384   +  1         +  2      +  469915           +  HDWR-MIS-00023
151382      +  151383    +  151372   +  2         +  2      +  469916           +  HDWR-MIS-00024
151382      +  151383    +  151373   +  3         +  2      +  469917           +  HDWR-MIS-00025
151382      +  151383    +  151374   +  4         +  2      +  469918           +  HDWR-MIS-00026
151382      +  151382    +  149079   +  3         +  1      +  469909           +  PANL-SAT-00300
151382      +  151382    +  151344   +  4         +  1      +  469910           +  SRVC-GEN-00014
151382      +  151382    +  149441   +  5         +  1      +  469911           +  PANL-BAK-00284
151382      +  151382    +  150776   +  17        +  1      +  469912           +  FOAM-KIT-00595
151382      +  151382    +  150765   +  18        +  1      +  469913           +  HDWR-BRK-00015
151382      +  151382    +  150810   +  20        +  1      +  469914           +  FABR-DOUX-00004

Item BOM looks like

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786

1 Answers1

0

I found a column in my tables that helped me sort the way I want. unfortunately, this question will not benefit anyone and I found no way of deleting this question.