Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

invalid relational operator

Hi,

I try to load data with some specific formula, my code is as below, but I receive an error message "invalid relational operator":

LOAD

A,

B,

C,

D,

VALID_FROM,

VALID_TO,

E;

SQL SELECT

A, 

B,

C,

D,

VALID_FROM,

VALID_TO,

E

FROM table

where A='A'

and B='B'

and not isnull("VALID_FROM")

and "VALID_TO">"VALID_FROM" or isnull("VALID_TO")

and isnull(E);

Is there naything wrong with the formula?

Peter

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try below Script.

    

SQL SELECT

A, 

B,

C,

D,

VALID_FROM,

VALID_TO,

E

FROM table

where A='A'

and B='B'

and not isnull(VALID_FROM)

and (VALID_TO>VALID_FROM or isnull(VALID_TO))

and isnull(E);

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

7 Replies
Sokkorn
Master
Master

Hi Peter

Let try this way

LOAD

    A,

    B,

    C,

    D,

    VALID_FROM,

    VALID_TO,

    E Where A='A' and B='B' and Not IsNull([VALID_FROM]) and ([VALID_TO]>[VALID_FROM] or IsNull([VALID_TO])) and IsNull(E);

SQL SELECT

    A,

    B,

    C,

    D,

    VALID_FROM,

    VALID_TO,

    E

FROM DAREO."ITEM_SU_T";

Not applicable
Author

try this

LOAD

A,

B,

C,

D,

VALID_FROM,

VALID_TO,


E

where A='A'

and B='B'

and not isnull("VALID_FROM")

and "VALID_TO">"VALID_FROM" or isnull("VALID_TO")

and isnull(E);


SQL SELECT

A, 

B,

C,

D,

VALID_FROM,

VALID_TO,

E

FROM table;

Not applicable
Author

try this

LOAD

A,

B,

C,

D,

VALID_FROM,

VALID_TO,


E

where A='A' and B='B' and VALID_FROM <>' ' and num(VALID_TO) > num(VALID_FROM) or VALID_TO=' ' and E=' ';


SQL SELECT

A, 

B,

C,

D,

VALID_FROM,

VALID_TO,

E

FROM table;

er_mohit
Master II
Master II

Try this way

LOAD

A,

B,

C,

D,

VALID_FROM,

VALID_TO,

E

where A='A'

and B='B'

and [VALID_FROM]<>' '

and [VALID_TO]>[VALID_FROM] or isnull([VALID_TO])

and isnull(E);

SQL SELECT

A,

B,

C,

D,

VALID_FROM,

VALID_TO,

E

FROM table;

or this

LOAD

A,

B,

C,

D,

VALID_FROM,

VALID_TO,

E

where A='A'

and B='B'

and [VALID_FROM]<>' '

and [VALID_TO]>[VALID_FROM] or [VALID_TO]=' '

and E=' ';

SQL SELECT

A,

B,

C,

D,

VALID_FROM,

VALID_TO,

E

FROM table;


Not applicable
Author

Hi er.mohit,

Thanks but I'm afraid that I may have not made my formula clear, so the 'or' function doesn't work as I want, it loads into a lot of things that I don't need.

What I need to do is to apply the 'or' function only to [VALID_TO], meaning to load only if [VALID_TO] is null, if it's not null then load those [VALID_TO]>[VALID_FROM].

Is it possible to make that happen?

BR/Peter

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try below Script.

    

SQL SELECT

A, 

B,

C,

D,

VALID_FROM,

VALID_TO,

E

FROM table

where A='A'

and B='B'

and not isnull(VALID_FROM)

and (VALID_TO>VALID_FROM or isnull(VALID_TO))

and isnull(E);

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi try this..

SET SQL“SELECT

  A,

  B,

C,

D,

VALID_FROM,

VALID_TO,

E

From Source table”;

LOAD
*
; $(SQL) where
A='A' and B='B'

and not isnull(VALID_FROM)

and VALID_TO > VALID_FROM or isnull(VALID_TO)

and isnull(E);