I have a simple table containing Student Numbers and corresponding Teacher Numbers, and I need to denormalize it for input to a legacy system.
For example, here's what the data looks like now:
StudNumber TeacherNumber
445 57315
445 88584
445 95842
858 88115
858 65443
858 57315
858 21144
858 18657
858 88584
311 64521
665 35512
665 57315
665 15546
What I'd like it to look like is this, splitting out each Teacher into a separate column, filling columns from left-to-right. One business rule is that each student can have no more than six teachers:
StudNum Teacher1 Teacher2 Teacher3 Teacher4 Teacher5 Teacher6
445 57315 88584 95842
858 88115 65443 57315 21144 18657 88584
311 64521
665 35512 57315 15546
There are 10,000+ rows in the original table, so I need to do this programatically.
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…