Sample Header Ad - 728x90

Using tablenames from a config table for joins

0 votes
1 answer
29 views
SELECT
    $model_master_id$,
    $model_market_segment$,
    $country$,
    $ctry_cd$,
    $score_run_id$,
    $period_id$,
    $prediction_from_dt$,
    $prediction_to_dt$,
    $buy_acq$,
    $eval_prd$,
    $scr.model_score$,
    $scr.model_score_bin$
    from 
    (select 
    model_master_id,
    model_version_id,
    score_run_id,
    $site_rsdnc_id$,
    segment_name,
    model_score,
    model_score_bin
    FROM $master_scoring_table_name$) scr
    LEFT JOIN
    (SELECT
    $site_rsdnc_id$,
    $segment_column_name$ 
    FROM $feature_table_name$) f 
    ON f.$site_rsdnc_id$=scr.$site_rsdnc_id$;
Could there be a possibly simple way to achieve the above code from my attached excel Config other than dynamic sql? Everything within dollar quotes comes from my config. I tried dynamic sql with for loops but since I have multiple tablenames coming from my config the dynamic sql runs for a very long time. enter image description here
Asked by Reshmi Nair (31 rep)
Feb 3, 2022, 09:12 PM
Last activity: Feb 4, 2022, 07:51 AM