Skip to main content

Hello,

 

I have been working with a custom SQL for my data source. I have the columns that I want but I cannot get the joining of multiple tables to work. If someone can help and give me some tips with this that would be great.

 

I am just including the tables that I am trying to join.

 

These nicknames are what is used below:

 

comp and perf should be joined together on the column composite_id

perf and c should be joined together on the column composite_id

bench and c should be joined together on the column benchmark_id

b and c should be joined together on the column benchmark_id

 

Please let me know if I can help explain anything better.

 

FROM

 

dwrd_mart.v_me_composite comp,

 

dwrd_mart.v_me_comp_performance perf,

 

dwrd_mart.v_me_bmrk_performance bench,

 

dwrd_mart.v_me_benchmark b,

 

dwrd_mart.v_me_class_bmrk_rel c

 

WHERE

 

comp.composite_id = perf.composite_id

 

AND

 

comp.month_end_Date = (select max(month_end_Date) from dwrd_mart.v_me_composite where perf.composite_id=comp.COMPOSITE_ID)

 

AND

 

c.benchmark_id = b.benchmark_id

 

and

 

b.benchmark_id = bench.benchmark_id

 

Thank you!

2 answers
  1. Oct 2, 2017, 3:51 AM

    If this has still not been resolved, you can try this:

     

    SELECT [columns]

    FROM    dwrd_mart.v_me_composite comp,

            dwrd_mart.v_me_comp_performance perf,

            dwrd_mart.v_me_bmrk_performance bench,

            dwrd_mart.v_me_benchmark b,

            dwrd_mart.v_me_class_bmrk_rel c

    WHERE   comp.composite_id = perf.composite_id

    AND     perf.composite_id = c.composite_id

    AND     bench.benchmark_id = c.benchmark_id

    AND     c.benchmark_id = b.benchmark_id

    AND     comp.month_end_date = (

                                    SELECT   MAX(month_end_Date)

                                    FROM    dwrd_mart.v_me_composite

                                    WHERE   composite_id=comp.COMPOSITE_ID

                                  )

0/9000