2 Replies Latest reply: Mar 2, 2011 7:49 AM by Muncho Ts RSS

    Need Help here.

      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

        • Need Help here.
          Miguel Angel Baeyens de Arce

          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.