sql - select query on two tables with no unique keys -


i have 2 tables.

table1

 col1   col2  col3
100 1000 100 1000 100 1002 100 b 1003 100 c 1004

table2

 col1   col2  colc
100 1x 100 2x 100 3x 100 b 4x 100 c 5x

in above table colc value unique.

i want ouptput this, colc values unique here also.

 col1   col2  col3  colc
100 1000 1x 100 1000 2x 100 1002 3x 100 b 1003 4x 100 c 1004 5x

i have use col1 , col2 key join.

is possible that. got duplicates comming in first 2 records, when tried inner , left outer joins. tia

something this?

select   a.col1,   a.col2,   a.col3,   b.colc  (   select     row_number() on (partition col1, col2 order 1) r,     col1,     col2       table1   ) a,  (   select     row_number() on (partition col1, col2 order 1) r,     col1,     col2       table2   ) b   a.r = b.r ,         a.col1 = b.col1 ,         a.col2 = b.col2; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -