Mysql
 sql >> Database >  >> RDS >> Mysql

MySQL specifico Raggruppa per

Questo dovrebbe farlo:

select name, min(time), max(time)
from (
select
name, 
time,
@group_num := if(@name != name, @group_num + 1, @group_num) AS group_number,
@name := name
from yourTable
, (select @group_num := 1, @name := NULL) variables
order by id
) sq
group by group_number