azur-xrl

 

  利用变量实现

set @c_id:=null, @rownum:=0;
select
*
from
(SELECT t.*,
@rownum:= (case when @c_id = t.c_id then @rownum + 1 else 1 end) count,
@c_id:=t.c_id
FROM t_class_message t 
order by t.c_id asc, t.create_time desc ) T
where count < 4 ;

分类:

技术点:

相关文章: