select top 300000 * from mytable where mobile in (select top 40 a.mobile from mytable a) and province in (select top in b.province from mytable b) mobile,province,city
select top 300000 * from mytable where mobile in (select top 40 a.mobile from mytable a) and province in (select top 10 b.province from mytable b) mobile,province,city
select * from (select * row_number() over(order by mobile) as rownum, rank() over(order by mobile) as rnk, dense_rank() over(order by mobile) as densernk from mytable where province in ( select top 10 distinct province,newid() as id from mytable order by id) and mobile in (select top 40 distinct mobile ,newid() as id from mytable order by id ) order by mobile ,province) Where rnk>=750
tylbud() ``这个是不对的!号段mobile是按前7位来算的!
select * from (select * row_number() over(order by mobile) as rownum, rank() over(order by mobile) as rnk, dense_rank() over(order by mobile) as densernk from mytable where province in ( select top 10 distinct province,newid() as id from mytable order by id) and mobile in (select top 40 distinct mobile ,newid() as id from mytable order by id ) order by mobile ,province) Where rnk<=750你说MOBILE按前7位算,那看你的表结构中是如何存的了,如果分开存,你改一下字段就行了,否则你就用SUBSTRING函数就可以了。
where mobile in (select top 40 a.mobile from mytable a)
and
province in (select top in b.province from mytable b)
mobile,province,city
where mobile in (select top 40 a.mobile from mytable a)
and
province in (select top 10 b.province from mytable b)
mobile,province,city
row_number() over(order by mobile) as rownum,
rank() over(order by mobile) as rnk,
dense_rank() over(order by mobile) as densernk
from mytable where province in (
select top 10 distinct province,newid() as id from mytable order by id)
and mobile in
(select top 40 distinct mobile ,newid() as id from mytable order by id )
order by mobile ,province)
Where rnk>=750
row_number() over(order by mobile) as rownum,
rank() over(order by mobile) as rnk,
dense_rank() over(order by mobile) as densernk
from mytable where province in (
select top 10 distinct province,newid() as id from mytable order by id)
and mobile in
(select top 40 distinct mobile ,newid() as id from mytable order by id )
order by mobile ,province)
Where rnk<=750你说MOBILE按前7位算,那看你的表结构中是如何存的了,如果分开存,你改一下字段就行了,否则你就用SUBSTRING函数就可以了。