我有一张表 table
id countID
1 2
2 2
3 3
4 1
5 3
6 2
7 3
8 1
现在要在这张表中 查询countID 字段 中出相同 记录出现次数的一个排行
在table中countID中有2 3 1 重复出现 重复次数最多的拍照前面
我想得到这样的一个查询
countid
2
3
1
id countID
1 2
2 2
3 3
4 1
5 3
6 2
7 3
8 1
现在要在这张表中 查询countID 字段 中出相同 记录出现次数的一个排行
在table中countID中有2 3 1 重复出现 重复次数最多的拍照前面
我想得到这样的一个查询
countid
2
3
1
解决方案 »
- 这样的SQL语句该怎么写呢(SQLSERVER2005)
- 请求一个存储过程
- 这是怎么回事?说“不支持support distributed transactions”
- 让一个表上的触发器使用一个存储过程返回的OUT参数
- regsvr32 注册态动库失败
- 请教:在SELECT语句中增加一个虚拟字段,根据条件,决定此字段的值。
- 数据库的"等待"类型
- 参考一下,这样的人在深圳能值多少钱?
- 本人本科,96年毕业,熟悉 vc++,vb,asp,sqlserver,有项目经历,初来上海,急于求职,可接受无薪工作!!!请版主暂不要删,人才热线那实在
- sql 6.5升级
- 请大家帮忙修改一下触发器,谢谢
- 菜鸟问题
FROM TableName
GROUP BY countid
ORDER BY COUNT(DISTINCT countid) DESC
---..
SELECT countid
FROM TableName
GROUP BY countid
ORDER BY COUNT(countid) DESC
--测试数据
create table 表(id int,countID int)
insert into 表
select 1,2 union all
select 2,2 union all
select 3,3 union all
select 4,1 union all
select 5,3 union all
select 6,2 union all
select 7,3 union all
select 8,1
select countID from 表
group by countID
order by count(countID) desc