SQLServer获取每组前10%的数据

sqlserver2005有关键字ntile(x)和over(partition by.. order by..)子句配合.

比如获取每个表的前10%个字段。

select id , name , colid , rn from(
select * , rn = ntile( 10)
over( partition by id order by colorder)
from syscolumns ) t where rn = 1
更多 0

转载于:https://www.cnblogs.com/kevinGao/p/3589961.html

sqlserver2005有关键字ntile(x)和over(partition by.. order by..)子句配合.

比如获取每个表的前10%个字段。

select id , name , colid , rn from(
select * , rn = ntile( 10)
over( partition by id order by colorder)
from syscolumns ) t where rn = 1

猜你喜欢

转载自blog.csdn.net/weixin_33939843/article/details/93051637
今日推荐