Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to compare value in different table and without key

Hi All,

I got some questions on comparing value in different table.

Table A

Key
Value
110
220
330

Table B

Lower RangeUpper RangeClass
1020Y
2030Y
010N

I would like to ask how to check which Key in table A belong to Class Y in Table B

Best Regards,

Louis

4 Replies
sushil353
Master II
Master II

Hi,

TableA:

Mapping load * inline

[

Value,Class

10,Y

20,Y

30,Y

];

TableB:

load ApplyMap('TableA',Lower Range,'N') as Class,* inline

[

Loser Range,Upper Range

10,20

20,30

0,10

];

HTH

Sushil

Anonymous
Not applicable
Author

Thx for reply!

The column Class does not exist in Table A.

sushil353
Master II
Master II

Try this


TableA:

Mapping load 'Y' as Class,* inline

[

Value

10

20

30

];

jonathandienst
Partner - Champion III
Partner - Champion III

Use an interval match in the pattern:

Let epsilon = 1e-9;

A:

LOAD Key,

  Value

FROM ...table A...

Left Join (A)

IntervalMatch(Value)

LOAD [Lower Range],

  [UpperRange] - epsilon as [Upper Range]

FROM ...table B...

Left Join (A)

LOAD [Lower Range],

  [UpperRange] - epsilon as [Upper Range],

  Class

FROM ...table B...


Replace the ellipses with the correct FROM clauses for your requirements. The value epsilon is a small amount to make sure that a value like 10 does not get assigned two class values.

You can drop the field [Lower Range] and [Upper Range] if you have no further need for them.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein