So given the table structure of 2 tables:
line_item
line_item_id item_id a_basic a_original b_basic b_original c_basic c_original
1 1 NULL 5 NULL 2 NULL 1
2 1 NULL 6 NULL 100 NULL 5
3 2 NULL 10 NULL 50 NULL 15
4 2 NULL 2 NULL 12 NULL 100
item
item_id rate
1 1.5
2 2
I need to populate the null values in the line_item table using this calculation:
item.rate x x_original
so for line_item_id: 1, it would be
a_original x item_id.rate (5 x 1.5)
Is this possible in a SQL script that supports sql server and mysql?
Note that we cannot use views or computed columns as a requirement.
coalesce(original_column, item.rate x x_original)?