日期:2014-05-17 浏览次数:20511 次
create table 第一张表
(ID int, Name varchar(10), Sex varchar(10))
insert into 第一张表
select 100, '张三1', 'true' union all
select 100, '张三2', 'true' union all
select 100, '张三3', 'true' union all
select 210, '李四1', 'false' union all
select 210, '李四2', 'false'
create table 第二张表
(ID int, Salary int)
insert into 第二张表
select 100, 5000 union all
select 100, 6000 union all
select 100, 7000 union all
select 210, 8000 union all
select 210, 9000
select t1.ID, t1.name, t1.Sex, t2.Salary
from
(select ID,name,Sex,
row_number() over(order by (select 0)) 'rn'
from 第一张表) t1
inner join
(select ID,Salary,
row_number() over(order by (select 0)) 'rn'
from 第二张表) t2 on t1.rn = t2.rn
/*
ID name Sex Salary
----------- ---------- ---------- -----------
100 张三1 true 5000
100 张三2 true 6000
100 张三3