SQLServer ntile获取每组前10%的数据
程序员文章站
2022-09-06 14:27:23
比如获取每个表的前10%个字段。 复制代码 代码如下: select id , name , colid , rn from ( select * , rn = ntile...
比如获取每个表的前10%个字段。
select id , name , colid , rn from (
select * , rn = ntile (10 )
over (partition by id order by colorder )
from syscolumns )t where rn = 1
复制代码 代码如下:
select id , name , colid , rn from (
select * , rn = ntile (10 )
over (partition by id order by colorder )
from syscolumns )t where rn = 1