我想要一个能给我想要的输出的查询,我正在使用以下查询
select table1.name1,table2.address
from table1 join table2
on(table1.key=table2.key);
它给了我结果加入螺母后,每个键只需要一行。
任何帮助将不胜感激。
如果允许任何组合但每个键只有一行,请尝试以下操作:
select table1.name1, MAX(table2.address) address
from table1
join table2
on table1.key=table2.key
group by table1.name1
试试这样
select *
from (select table2.address,
rank() over ( partition by table1.name1 order by table1.key) rn
from table1 join table2 on(table1.key=table2.key))
where rn = 1