Skip to content
Advertisement

How to create teble 3 from data of table 1 and table 2

t1 (ordered descending):

a comment
512 (ordered desc)
415
310
205
195
150
132
90
74
20
1

t2 (ordered ascending):

b comment
10 (ordered asc)
11
12
13

I would like to create t3:

a (desc) b comment
512 10 (b=asc)
415 11
310 12
205 13
195 13 (b=desc)
150 12
132 11
90 10
74 10 (b=asc)
20 11
1 12

etc.

In table t3, a is data from t1, and b is data from t2.

Advertisement

Answer

You can add a sequence number and then join using arithmetic:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement