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

To get min date in the interval range of a field

Hi Everyone,

I have 2 tables,

Table 1 : Sim Data

SOR_IDDEVICE_START_DTEQP_DEVICE_ID
V28-Apr-21350039000000000
V14-Apr-21350039000000000
V19-May-21350039000000000
V19-May-21350039000000000
V21-Feb-20350039000000000
V21-May-21350039000000000
V17-May-21350039000000000
V30-Mar-21350039000000000
V11-Oct-19350039000000000
V21-May-21350039000000000
V12-Jun-21350039000000000
V3-Jul-21350039000000000
V19-May-21350039000000000
V11-May-21350039000000000
V26-May-21350039000000000
V18-Mar-21350039000000000
V19-Jun-21350039000000000
V10-Apr-21350131000000000
V19-May-21350131000000000
V30-Jun-21350131000000000
V19-May-21350131000000000
V17-May-21350131000000000
V14-May-21350131000000000
V9-May-21350131000000000
V19-May-21350131000000000
V18-May-21350131000000000
V20-May-2115588000000000
V7-May-2115588000000000
V10-Apr-2115588000000000
V6-May-2115588000000000
V19-May-2115588000000000
V18-May-2115588000000000
V30-Jun-2115588000000000

Table 2 : Activation

SOR_IDEFF_DTEXP_DTEQP_DEVICE_ID
V29-Mar-2113-Apr-2115588000000000
V1-Apr-2116-Apr-2115588000000000
V13-May-2128-May-2115588000000000
V5-May-2120-May-2115588000000000
V11-May-2126-May-2115588000000000
V9-May-2124-May-21350039000000000
V11-May-2126-May-21350039000000000
V11-May-2126-May-21350039000000000
V16-May-2131-May-21350039000000000
V17-May-211-Jun-21350039000000000
V17-May-211-Jun-21350039000000000
V18-May-212-Jun-21350039000000000
V18-May-212-Jun-21350039000000000
V20-May-214-Jun-21350039000000000
V21-May-215-Jun-21350039000000000
V21-May-215-Jun-21350039000000000
V21-May-215-Jun-21350039000000000
V7-Jun-2122-Jun-21350039000000000
V10-Jun-2125-Jun-21350039000000000
V30-Jun-2115-Jul-21350039000000000
V10-Jun-2125-Jun-21350131000000000
V30-May-2114-Jun-21350131000000000
V21-Jun-216-Jul-21350131000000000
V10-May-2125-May-21350131000000000

 

In the above mentioned tables, we need to get the interval dates of Device_Start_Date based on EFF_Dt & Exp_Dt

By using the code given below,

SIM_DATA:
LOAD
DEVICE_START_DT,
EQP_DEVICE_ID as DEVICE_ID
FROM [lib://AttachedFiles/SIM_DEVICE_DATA.xlsx]
(ooxml, embedded labels, table is SIM_DEVICE_DATA);


Activation:
LOAD
EFF_DT,
EXP_DT,
MTN,
EQP_DEVICE_ID as DEVICE_ID
FROM [lib://AttachedFiles/SIM_DEVICE_DATA.xlsx]
(ooxml, embedded labels, table is ACTIVATIONS_DEVICE_DATA);

tmp:

inner Join (Activation)
IntervalMatch(DEVICE_START_DT, DEVICE_ID)
load EFF_DT, EXP_DT, DEVICE_ID
Resident Activation;

got the output as given below which is correct.

DEVICE_IDEFF_DTEXP_DTInterval Dt
35003900000000009-May-202124-May-202111-May-2021
35003900000000009-May-202124-May-202117-May-2021
35003900000000009-May-202124-May-202119-May-2021
35003900000000009-May-202124-May-202121-May-2021
35003900000000011-May-202126-May-202117-May-2021
35003900000000011-May-202126-May-202119-May-2021
35003900000000011-May-202126-May-202121-May-2021
35003900000000011-May-202126-May-202126-May-2021
35003900000000016-May-202131-May-202117-May-2021
35003900000000016-May-202131-May-202119-May-2021
35003900000000016-May-202131-May-202121-May-2021
35003900000000016-May-202131-May-202126-May-2021
35003900000000017-May-202101-Jun-202119-May-2021
35003900000000017-May-202101-Jun-202121-May-2021
35003900000000017-May-202101-Jun-202126-May-2021
35003900000000018-May-202102-Jun-202119-May-2021
35003900000000018-May-202102-Jun-202121-May-2021
35003900000000018-May-202102-Jun-202126-May-2021
35003900000000020-May-202104-Jun-202121-May-2021
35003900000000020-May-202104-Jun-202126-May-2021
35003900000000021-May-202105-Jun-202126-May-2021
35003900000000007-Jun-202122-Jun-202112-Jun-2021
35003900000000007-Jun-202122-Jun-202119-Jun-2021
35003900000000010-Jun-202125-Jun-202112-Jun-2021
35003900000000010-Jun-202125-Jun-202119-Jun-2021
35003900000000030-Jun-202115-Jul-202103-Jul-2021

 

Now my requirement is to get the Min Date & Max Date from the Interval Date in the above table.

How can I achieve it.

Please suggest.

Thanks in Advance.

0 Replies