mercredi 25 mars 2015

Populating a table with data from a table that has the historical data on columns (SQL/plSQL 10g)


I have to populate a table with information from a table that has the historical data on columns. The source table name is source table xxtbl_source(client_id number, dec_14 number, nov_14 number, oct_14 number, sep_14 number, aug_14 number, jul_14 number, jun_14 number, may_14 number, apr_14 number, mar_14 number, feb_14 number, jan_14 number). xxtbl_source


The destination table name is xxtbl_destination(client_id number, evaluation_date, val_mth_1 number, val_mth_2 number, val_mth_3 number, val_mth_4 number, val_mth_5 number, val_mth_6 number, val_mth_7 number, val_mth_8 number, val_mth_9 number, val_mth_10 number, val_mth_11 number, val_mth_12 number). xxtbl_destination


The rule to insert the data is: -for val_mth_1 i have to insert the value from the column that corresponds to add_months(evaluation_date, -1) ; one month before the evaluation_date -for val_mth_2 i have to insert the value from the column that corresponds to add_months(evaluation_date, -2) ; the months before the evaluation_date -for val_mth_3 i have to insert the value from the column that corresponds to add_months(evaluation_date, -3) ; three months before the evaluation_date -and so on......


I am waiting for your solution. Thank you very much for your effort.





Aucun commentaire:

Enregistrer un commentaire