日期:2014-05-17 浏览次数:20655 次
create table tb(v int)
insert into tb
select 1 union all
select 10 union all
select 6 union all
select 8 union all
select 2 union all
select 18 union all
select 5 union all
select 10 union all
select 11 union all
select 90
go
;with t
as
(
select *,
ROW_NUMBER() over(order by @@servername) rownum
from tb
)
select t1.*,t1.v *1.0/ t2.v as vv
from t t1
inner join t t2
on t1.rownum +4 = t2.rownum
/*
v rownum vv
1 1 0.500000000000
10 2 0.555555555555
6 3 1.200000000000
8 4 0.800000000000
2 5 0.181818181818
18 6 0.200000000000
*/