I need to create a new table from the data that I extract from the following two tables:
First table:
Var cur_number
Second table:
Var new_number
The new table should contain the Var column and the Number column, where for each variable there will be one row with its cur_number number, and the remaining rows will contain numbers from the columns of the second new_number column, where new_number <cur_number. For example, in the example shown above, for A there will be one line with 10 (its cur_number) and one line with "2" (since 2 <10, however 11> 10).
in my example, the new table will be:
Var Number A 10 A 2 B 8 B 4 B 6
The database is very large, and runtime is critical, so I cannot use UNION for two tables ...
source share