New answers tagged

0

You can use variables for this kind of thing: select userId, count(*) from ( select @g:=case when userId=@lastuserId then @g else @g+1 end AS grp, @lastuserId:=userId AS userId from test1, (select@lastuserId:=0, @g:=0) vars order by transactionTime ) groups group by grp, userId order by grp



Top 50 recent answers are included