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

Joining 2 tables with periods

I've got problem with joining tables.
Source tables look like that:
TAB1
START
END
EMPL_KEY
EMPL_ID
STATUS
COMPANY_NO
1989-02-15
2007-02-08
123#1
1356
1
1
2008-09-24
 
124#2
1356
1
2
 
 
125#UMC
1356
0
1
2010-10-01
2011-02-26
222#1
7330
1
1
2011-07-01
2017-02-15
223#1
7330
1
1
2011-08-02
 
333#1
7727
1
1
2016-07-12
2019-07-11
444#1
10438
1
1
 
TAB2:
AB_START
AB_END
AB_ID 
AB_EMPL_ID
AB_COMPANY_NO
1999-09-01
1999-09-19
1202532
1356
1
2009-11-03
2009-11-07
1202533
1356
2
2011-01-10
2011-01-10
1202549
7330
1
2010-11-02
2010-11-05
1202550
7330
1
2016-05-10
2016-05-15
1202563
1356
1
2012-03-03
2012-03-12
1344561
7727
1
2019-03-04
2019-03-10
1561688
10438
1
 
DESTINATION TABLE:
AB_START
AB_END
AB_ID 
AB_EMPL_ID
AB_COMPANY_NO
EMPL_KEY
1999-09-01
1999-09-19
1202532
1356
1
123#1
2009-11-03
2009-11-07
1202533
1356
2
124#2
2011-01-10
2011-01-10
1202549
7330
1
222#1
2011-11-02
2011-11-05
1202550
7330
1
223#1
2016-05-10
2016-05-15
1202563
1356
2
124#2
2012-03-03
2012-03-12
1344561
7727
1
333#1
2019-03-04
2019-03-10
1561688
10438
1
444#1
 
I've tried intervalmatch
 
EMPL_ID&'#'&"COMPANY_NO"&'#'&'STATUS' as AB_KLUCZ
AB_EMPL_ID&'#'&"AB_COMPANY_NO"&'#'&'1' as AB_KLUCZ
INTERVAL:
IntervalMatch("AB_START",AB_KLUCZ)
LOAD
START,
END,
AB_KLUCZ
Resident TAB1 where STATUS=1;

LEFT JOIN TAB2
 
But it gave me multiple periods in table 2.
 
I am Not sure if I express myself clearly but thank you in advance for your help
PS... EMPL_KEY is The Key in Tab1 nad AB_ID is The Key in TAB2.
 
Regards
0 Replies