希望能根据ID来实现queueWaitCount的排序,如id为2的只有一条,希望queueWaitCount为1,此类排序,谢谢
mysql查询根据类别排序
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- 月半杰 2019-05-20 16:06关注
凑活着看吧,不是很好,但能实现要求
set @a=0;
set @pd=0;
select pooid,count,queueWaitCount from (
select case when pooid=@pd then @a:=@a+1 else @a:=1 end as queueWaitCount , @pd:=pooid as pooid from test order by pooid) a ,
(select pooid pd,count(1) count from test group by pooid)b where pd=pooid本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报