Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
This 1st table is the Data table I have, with master and sub different, in the 2nd table the sub items having SID = MID s of their respective Master items re arranged below them. I want to arrange the sub items below their master items with the help of MIDs. How can I do it? Urgent.
note- each sub item's SID is equal to its respective master item's MID.
Table1: :
Relationship | MID | SID |
Master | nil | 100 |
Master | nil | 600 |
Master | nil | 200 |
sub | 100 | 1291 |
sub | 200 | 1292 |
sub | 100 | 1293 |
Master | nil | 400 |
sub | 600 | 1298 |
Table 2:
Relationship | MID | SID |
Master | nil | 100 |
sub | 100 | 1291 |
sub | 100 | 1293 |
Master | nil | 200 |
sub | 200 | 1292 |
Master | nil | 400 |
Master | nil | 600 |
sub | 600 | 1298 |
One solution is:
tab1:
LOAD * INLINE [
Relationship, MID, SID
Master , nil, 100
Master , nil, 600
Master , nil, 200
sub , 100, 1291
sub , 200, 1292
sub , 100, 1293
Master , nil, 400
sub , 600, 1298
];
mapMaster:
Mapping
LOAD SID, Relationship&'/'&SID
Resident tab1;
tab2:
LOAD *, If(Relationship='Master',
Relationship&'/'&SID,
ApplyMap('mapMaster',MID)) As %Sort
Resident tab1;
Drop Table tab1;
tab1:
LOAD * INLINE [
Relationship, MID, SID
Master , nil, 100
Master , nil, 600
Master , nil, 200
sub , 100, 1291
sub , 200, 1292
sub , 100, 1293
Master , nil, 400
sub , 600, 1298
];
mapMaster:
Mapping
LOAD SID, Relationship&'/'&SID
Resident tab1
Where Relationship='Master';
tab2:
LOAD *, If(Relationship='Master',
Relationship&'/'&SID,
ApplyMap('mapMaster',MID)) As %Sort
Resident tab1;
Drop Table tab1;