新手求一简单sql语句

hq2008 2006-11-24 06:55:37
有一个会员表,我想按省份统计出各个省份的前100个会员的信息,sql语句怎么写
...全文
117 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hq2008 2006-11-24
  • 打赏
  • 举报
回复
谢谢啦!
xiaoku 2006-11-24
  • 打赏
  • 举报
回复
--没测试过...lz看看行不行?
--是在userid 没有重复的情况下使用
select *
from userT a
where userid in (select top 100 userid from userT where province =a.province order by userid )
gc_ding 2006-11-24
  • 打赏
  • 举报
回复
select * from 会员表 a
where
(select count(*) from 会员表 where province = a.province and username > a.username) < 100
xiaoku 2006-11-24
  • 打赏
  • 举报
回复
userid 有重复?


5 sdfds 山东 h@email.com
5 sdfds 山东 h@email.com
5 sdfds 山西 h@email.com

---?
hq2008 2006-11-24
  • 打赏
  • 举报
回复
userid username province email
1 sdfds 广东 h@email.com
2 ssdffds 广东 h@email.com
3 sdfsdfdds 湖南 h@email.com
4 sdfds 湖南 h@email.com
5 sdfds 山东 h@email.com
5 sdfds 山东 h@email.com
5 sdfds 山西 h@email.com
. . . .
. . . .
. . . .
xiaoku 2006-11-24
  • 打赏
  • 举报
回复
有id马?

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧