如果按在数据库中的次数选择

Dabay 2006-08-14 04:24:47
比如表是这样的

number
--------
one
two
three
one
three
one
--------

我想得到这样的结果

---------
one 3
three 2
two 1
---------

后面的数据表示在表中出现的次数. 谢谢!!!
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dabay 2006-08-14
  • 打赏
  • 举报
回复
select number,count(*) as counter from tablename group by number order by counter desc
blackbinbin 2006-08-14
  • 打赏
  • 举报
回复
select number ,count(*) from tablename group by number
lxzm1001 2006-08-14
  • 打赏
  • 举报
回复
select number,count(*) from tablename group by number

22,210

社区成员

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

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