I have a table which contains the following:
Table1
ID Range Rate
1 A,B,C,D,E,F 1.2
2 A,B,C 3.1
and another table:
Table2
ID A B C D E F G H J K
1 1 2 1 3 4 2 4 5 8 1
2 1 2 1 3 4 2 4 5 8 1
Basically this tells us which columns we can apply the rate to, e.g we can apply the rate 1.2 to values that are stored in columns A,B,C,D,E,F of table2 and rate of 3.2 should be applied to columns A,B and C only.
I am joining the two table on the ID column
Select * From Table1
Inner Join Table2 ON Table1.ID = Table2.ID
But what I am trying to achieve is after joining the 2 tables to select the columns from Table2 based on the contents of the Range column of Table1.
Based on the above example, from the Table1 the first column's range field has: A,B,C,D,E,F so from Table2, I am trying to select only columns A,B,C,D,E,F and apply the rate (1.2) to all of them and leave the rest of the columns untouched, so the solution will look like this:
ID A B C D E F G H J K
1 1*1.2 2*1.2 1*1.2 3*1.2 4*1.2 2*1.2 4 5 8 1
2 1*3.1 2*3.1 1*3.1 3 4 2 4 5 8 1
Hope this makes sense.
Thanks