Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nicolai_moller
Contributor
Contributor

Fields from different tables in one if statement

Hi

I need to create an if statement that uses fields from two different fields.

Something like this.

load

A

FROM ...

load

B

FROM ...

load

if(A>B,1,0) as TEST

resident ?

So I guess I have to create the IF statement in a third table? But how do I link them together?

Thanks.

1 Solution

Accepted Solutions
Not applicable

try this

table1:

load

A,

rowno() as key

FROM table1;

outer join

table2:

load

B,

rowno() as key

FROM table2;

table3:

load

if(A>B,1,0) as TEST

resident table1;

View solution in original post

3 Replies
Not applicable

you must have an relation between column A and B (join the tables or union them in one table and you can do that)

Not applicable

let say tab1:

id A

1 data1

2 data2

3 data3

4 data4

let say tab2:

id B

1 val1

2 val2

3 val3

4 val4

if you

*****************

left join (tab1)

load * resident tab2;

****************

will modify tab1 like:

id A B

1 data1 val1

2 data2 val2

3 data3 val3

4 data4 val4

and after that you can load (because now he knows to compare on every row).

Make sure you have a field (this case id) that is the same in both table , this is where the join is made.

load *,

if(A>B,1,0) AS TEST

resident tab1;

Hope that helps.

Not applicable

try this

table1:

load

A,

rowno() as key

FROM table1;

outer join

table2:

load

B,

rowno() as key

FROM table2;

table3:

load

if(A>B,1,0) as TEST

resident table1;