Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

Table join

Hi

I have 3 following table and want to join them to obtain requried output report

   

Table 1
POLICY_NOPOLICY_PERIODPREMIUM
1NOV-10-NOV-114000
2DEC-12-DEC-135000
3JAN-14-JAN-152000

   

Table 2
POLICY_NOPOLICY_PERIODPAID
1NOV-10-NOV-1130000
2DEC-12-DEC-1325000
1NOV-10-NOV-1112000
2DEC-12-DEC-134000

     

Table 3
POLICY_NOPOLICY_PERIODTYPERATEAMOUNT
1NOV-10-NOV-11BASIC2000
1NOV-10-NOV-11NCB10-250
1NOV-10-NOV-11LOADING 400
2DEC-12-DEC-13BASIC2500
2DEC-12-DEC-13NCB20-400
2DEC-12-DEC-13LOADING500
3JAN-14-JAN-15BASIC1500

     

OUTPUT REPORT
POLICY_NOPOLICY_PERIODPREMIUMPAIDBASICNCBRATELOADING
1NOV-10-NOV-114000300002000-25010400
12000
2DEC-12-DEC-135000250002500-40020500
4000
3JAN-14-JAN-1520000

1500

Appreciate very much your  help with a sample report for the above

13 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

The Result table contains the content after running this script:

Result:

LOAD * Inline

[

POLICY_NO POLICY_PERIOD PREMIUM

1 NOV-10-NOV-11 4000

2 DEC-12-DEC-13 5000

3 JAN-14-JAN-15 2000

] (delimiter is '\t');

Left Join (Result)

LOAD POLICY_NO, PAID

Inline

[

POLICY_NO POLICY_PERIOD PAID

1 NOV-10-NOV-11 30000

2 DEC-12-DEC-13 25000

] (delimiter is '\t');

T3: 

LOAD * Inline

[

POLICY_NO POLICY_PERIOD TYPE RATE AMOUNT

1 NOV-10-NOV-11 BASIC 2000

1 NOV-10-NOV-11 NCB 10 -250

1 NOV-10-NOV-11 LOADING 400

2 DEC-12-DEC-13 BASIC 2500

2 DEC-12-DEC-13 NCB 20 -400

2 DEC-12-DEC-13 LOADING 500

3 JAN-14-JAN-15 BASIC 1500

] (delimiter is '\t');

Left Join (Result)

LOAD POLICY_NO,

  RATE As BASIC

Resident T3

Where TYPE = 'BASIC';

Left Join (Result)

LOAD POLICY_NO,

  RATE As RATE,

  AMOUNT AS NCB

Resident T3

Where TYPE = 'NCB';

Left Join (Result)

LOAD POLICY_NO,

  AMOUNT AS LOADING

Resident T3

Where TYPE = 'LOADING';

DROP Table T3;


t1.png
You have duplicate lines in Table2 with different values. I am not sure how you want to handle these as the data is not in the final report, so I only loaded the first instance of each policy for table 2.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Digvijay_Singh

I am finding your structure very strange, can you answer below questions to understand requirements better -

1. AMOUNT heading is lost in final report but its values are used somewhere in final report, not sure how?

2. TYPE column values of third table it seems are required as columns in final report But RATE is still there with few values, other values distributed for new columns, how?

3. 12000,4000 PAID values are shown in final report below POLICY_NO, why?

Digvijay_Singh

I think you have used RATE as LOADING in the last join to reflect your shown result. But in the requirement in 3rd table, 400 value is showing under Amount, might be a typo.

kavita25
Partner - Specialist
Partner - Specialist

PFA..

I have a doubt for 12000 and 4000 values under policy no..where to reflect this values under policy no?? and why ??

Rest of the part is completed...

Regards,

Kavita

upaliwije
Creator II
Creator II
Author

That should come under paid  12000 and 4000

kavita25
Partner - Specialist
Partner - Specialist

It means for NOV-10-NOV-11 it should be 30000+12000 i.e 42000  and for DEC-12-DEC-13 4000+25000 i.e 29000 under PAID  Right ???

upaliwije
Creator II
Creator II
Author

Yes

kavita25
Partner - Specialist
Partner - Specialist

See the attached qvw...

hope it helps you!!!

upaliwije
Creator II
Creator II
Author

File not attached. pls attach the same