Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Left join with where clause in load

TabA

a, b

1, '2011-01-01'

2, '2011-02-01'

2, '2011-03-01

TabB

c, d, e

1, '2011-01-01', '2011-01-31'

2, '2011-01-01', '2011-03-31'

Sample in the sql command:

select *

  from taba

left join tabb on a = c and b >= d and b <= e

How  can i do this in the load?

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hei
try this one
TabA:

LOAD * INLINE [

a, b

1, 01/01/2011

2,01/02/2011

2, 01/03/2011

2, 01/04/2011

]
;





LEFT JOIN (TabA)

LOAD c as a, c, d, e INLINE [

c, d, e

1, 01/01/2011, 31/01/2011

2, 01/02/2011,31/03/2011

]
;




LEFT JOIN (TabA)
LOAD b,
d as F,
e as G
RESIDENT TabA
WHERE b >= d AND b <= e;

drop fields d,e;

RENAME Field F to d;
RENAME Field G to e;

View solution in original post

6 Replies
SunilChauhan
Champion II
Champion II

TabA:

select a,b

from taba

TabB:

select c as a,

c

d,

e

from tabB

TabC:

Load

a,d,e,c

resident TabB

left join

Load

a,b

resident TabA;

TabD:

Load

a,b,d,e

resident TabC

where a = c and b >= d and b <= e;

drop tablesTabB,TabA,TabC ;

Sunil Chauhan
Not applicable
Author

I tried to load this script but not functioned.

TabA:

LOAD * INLINE [

a, b

1, '2011-01-01'

2, '2011-02-01'

2, '2011-03-01'

];

TabB:

LOAD c as a, c, d, e INLINE [

c, d, e

1, '2011-01-01', '2011-01-31'

2, '2011-02-01', '2011-01-01'

];

TabC:

Load

a,d,e,c

resident TabB;

left join Load

a,b

resident TabA;

TabD:

Load

a,b,d,e

resident TabC

where a = c

and b >= d

and b <= e;

drop tables TabB,TabA,TabC ;

johnw
Champion III
Champion III

I think this?

TabA:
LOAD * INLINE [
a, b
1, '2011-01-01'
2, '2011-02-01'
2, '2011-03-01'
];
LEFT JOIN (TabA)
LOAD c as a, c, d, e INLINE [
c, d, e
1, '2011-01-01', '2011-01-31'
2, '2011-02-01', '2011-01-01'
];
INNER JOIN (TabA)
LOAD *
RESIDENT TabA
WHERE b >= d AND b <= e;

Not applicable
Author

Hi John,

I need something a little different.

TabA:

LOAD * INLINE [

a, b

1, '2011-01-01'

2, '2011-02-01'

2, '2011-03-01'

2, '2011-04-01'

];

LEFT JOIN (TabA)

LOAD c as a, c, d, e INLINE [

c, d, e

1, '2011-01-01', '2011-01-31'

2, '2011-02-01', '2011-03-31'

];

LEFT JOIN (TabA)

LOAD *

RESIDENT TabA

WHERE b >= d AND b <= e;

I need the result below:

1, '2011-01-01',  '2011-01-01', '2011-01-31'

2, '2011-02-01',  '2011-02-01', '2011-03-31'

2, '2011-03-01',  '2011-02-01', '2011-03-31'

2, '2011-04-01',  null, null

Thanks


lironbaram
Partner - Master III
Partner - Master III

hei
try this one
TabA:

LOAD * INLINE [

a, b

1, 01/01/2011

2,01/02/2011

2, 01/03/2011

2, 01/04/2011

]
;





LEFT JOIN (TabA)

LOAD c as a, c, d, e INLINE [

c, d, e

1, 01/01/2011, 31/01/2011

2, 01/02/2011,31/03/2011

]
;




LEFT JOIN (TabA)
LOAD b,
d as F,
e as G
RESIDENT TabA
WHERE b >= d AND b <= e;

drop fields d,e;

RENAME Field F to d;
RENAME Field G to e;
Not applicable
Author

Thanks guys!