Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all.
I'm totally new in QV. I posted this few days ago. But i still have this problem. So i explain it little bit different.
I have 3 Table.
fact:
load * inline [
id, type, weigh
1047, normal, 0.7
2025, express, 0.3
1082, normal, 1.8
2093, express, 2.1
......
];
weight_for_express:
load * inline [
start, end, weight_sort
0.1, 0.5, 0.5
0.6, 1, 1
1.1, 1.5, 1.5
1.6, 2, 5
......
];
weight_for_normal:
load * inline [
start, end, weight_sort
0.1, 1, 1
1.1, 2, 2
2.1, 3, 3
3.1, 4, 4
......
];
I need use intervalmatch() to match weight then use it correct type.
How should i do this?
regards
Muncho
Hello Muncho,
According to your script above, the following should return what you want. IntervalMatch accepts as many keys needed (the type in this case) so the range could be identified.
fact:load * inline [id, type, weigh 1047, normal, 0.72025, express, 0.31082, normal, 1.82093, express, 2.1]; weight_for_express:load * inline [start, end, weight_sort, type0.1, 0.5, 0.5, express0.6, 1, 1, express1.1, 1.5, 1.5, express1.6, 2, 5, express]; weight_for_normal:load * inline [start, end, weight_sort, type0.1, 1, 1, normal1.1, 2, 2, normal2.1, 3, 3, normal3.1, 4, 4, normal]; FactsWithWeights: // This table will be the final one.INTERVALMATCH (weigh, type) LOAD start, end, typeRESIDENT weight_for_express;LEFT JOIN LOAD *RESIDENT fact; DROP TABLE fact;DROP TABLE weight_for_express;
Check the above on how to use intervalmatch with a discrete value and a key.
Hope that helps.
Hello Muncho,
According to your script above, the following should return what you want. IntervalMatch accepts as many keys needed (the type in this case) so the range could be identified.
fact:load * inline [id, type, weigh 1047, normal, 0.72025, express, 0.31082, normal, 1.82093, express, 2.1]; weight_for_express:load * inline [start, end, weight_sort, type0.1, 0.5, 0.5, express0.6, 1, 1, express1.1, 1.5, 1.5, express1.6, 2, 5, express]; weight_for_normal:load * inline [start, end, weight_sort, type0.1, 1, 1, normal1.1, 2, 2, normal2.1, 3, 3, normal3.1, 4, 4, normal]; FactsWithWeights: // This table will be the final one.INTERVALMATCH (weigh, type) LOAD start, end, typeRESIDENT weight_for_express;LEFT JOIN LOAD *RESIDENT fact; DROP TABLE fact;DROP TABLE weight_for_express;
Check the above on how to use intervalmatch with a discrete value and a key.
Hope that helps.
Hi Miguel
it looks working. Many thanks.