3 回答
TA贡献1802条经验 获得超5个赞
select ru_rask_name_, ru_rask_name_1, comment_, deal_time
from (
select ru_rask_name_, ru_rask_name_1, comment_, deal_time,
if(ru_rask_name_1 = @y, @x := @x + 1, @x := 1) x,
(@y := ru_rask_name_1)
from (select @x := 0) x, (select @y := 0) y, you_table
order by deal_time desc
) t where x = 1
order by deal_time;
TA贡献1817条经验 获得超14个赞
select ru_rask_name_, ru_rask_name_1, comment_, deal_time from (
select ru_rask_name_, ru_rask_name_1, comment_, deal_time,
if(ru_rask_name_1 = @y, @x := @x + 1, @x := 1) x, (@y := type), (@y := ru_rask_name_1)
from (select @x := 0) x, (select @y := 0) y, you_table
order by deal_time desc
) t ) t where t.x = 1;
先try一下吧.注意下,这是时间倒序取的..
其实还可以通过先正序,后序号和日期group by,但这样还需要再进行一次自关联查询..比较麻烦,就选了上者.
添加回答
举报