在Table中,我需要查出那个ID出现的频率最小,
select count(c1) from table where id=1,
select count(c1) from table where id=2
select count(c1) from table where id=3
select count(c1) from table where id=4,
最后查出来的结果理想是
0
1
2
3
不知道有没有好一点的思路,不想在代码里做个傻循环,需要注意的是ID可能为空
即select * from table where id=1有可能无结果集
数据库,求最小 group ,count,min
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
14条回答 默认 最新
threenewbee 2015-07-22 15:25关注select count(c1) as xx from table group by id order by xx
解决 无用评论 打赏 举报