SQLServer data retrieval of the first 10% of each

sqlserver2005 have keywords ntile (x) and over (partition by .. order by ..) with clause.

Such as access to the top 10% of the fields in each table.

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

Reproduced in: https: //www.cnblogs.com/kevinGao/p/3589961.html

sqlserver2005 have keywords ntile (x) and over (partition by .. order by ..) with clause.

Such as access to the top 10% of the fields in each table.

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

Guess you like

Origin blog.csdn.net/weixin_33939843/article/details/93051637