Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I've got a table like this:
pstart | pend | pdesc |
1 | 3 | car |
10 | 12 | van |
15 | 16 | truck |
This table differs per customer.
Anyone suggestions how to rebuild this table like;
1 car
2 car
3 car
10 van
11 van
12 van
15 truck
16 truck
Thanks in advance.
hi fred,
pls check the attached application
it shud work
thanks
Get the count of pdesc.
Then use 2 FOR loops to loop through each pdesc and assign all the numbers between pstart and pend to it.
In the inner loop - use concatenate LOAD.
Let me know if it works.
Hi Tauqueer,
Thanks! Just what I had in mind.
Rocky thanks for thinking along!
Tauqueer, I hope you don't mind to share your script with others, so others can view your solution without downloading the qvw.
mt:
LOAD * INLINE [
pstart, pend, pdesc
1, 3, car
10, 12, van
15 , 16, truck
];
let x=noofrows('mt');
for i=1 to $(x)
let y=fieldvalue('pstart',$(i));
let z=fieldvalue('pend',$(i));
for j= $(y) to $(z)
load $(j) as column1,fieldvalue('pdesc',$(i)) as column2 resident mt;
next j
next i
It's simpler and I suspect faster with a WHILE loop:
mt:
LOAD * INLINE [
pstart, pend, pdesc
1, 3, car
10, 12, van
15 , 16, truck
];
LEFT JOIN (mt)
LOAD *,pstart+iterno()-1 as pval
RESIDENT mt
WHILE pstart+iterno()-1 <= pend
;
Hi John,
Sounds like you know the answer to just any question.
Your solution is even better.
Thanks, you're a great help to this Community.
Fred