Need help for fetching Alias names for columns of a view from Reference table

Database
N/A

Need help for fetching Alias names for columns of a view from Reference table

I have a requirement as per which I have a reference table which contains names of the KPIs against the KPI_ID.Sample structure of this table along with data is :

 (table1)






mis_dt kpi_id kpi name
29/2/2012 kpi_1 new to bank customers
29/2/2012 kpi_2 cash loan customers

I have another table which contains the above mentioned KPI_IDs as individual columns having value for each KPI_ID.Sample structure along with data for this is:

 (table2)







mis_dt cust_nbr kpi_1 kpi_2
29/2/2012 101 10 100

Now,my requirement is to create a view,which on running gives me output in the following manner:







mis_dt cust_nbr new to bank cust cash loan cust
29/2/2012 101 10 100

i.e. the column names for columns kpi_1 and kpi_2 should be replaced by there respective kpi_name in the view and for this I have to use reference table(i.e. table1) and it has not to be implemented by hard coding alias names because as per my requirement the kpi_name can cahnge in the reference table(table1) and the same should reflect in the result when I run a select on the view.

In short :

"create or replace view test_view as

select

mist_dt

,cust_nbr

,kpi_1 "new to bank cust"

,kpi_2 "cash loan cust"

from table 2"  should  not be the solution.

the alias name for kpi_1,kpi_2 should come from reference table (table1).

Please help me as to how to implement it in teradata.Its an urgent requirement.