Assume the following two tables (and ignore the quality of the database design):
- Table 1 has columns
value: it contains many rows.
- Table 2 has columns
seq5: it is empty.
The goal is to fill Table 2 with Table 1's value, such that if in Table 1 one row is
sequence_number = 3;
value = 1564.1, then in Table 2 one should insert a row with
seq3 = 1564.1. (the other columns aside from
id should be empty).
How to do that in SQL? I don't want to hard code all 5 options (because in my actual use case there are over 50.), but I don't know how to condition the column name that should receive the value based on the value.