Could anyone explain this code to me？Leetcode #180 select distinct Num as ConsecutiveNums
from (
  select Num, 
    case 
      when @prev = Num then @count := @count + 1
      when (@prev := Num) is not null then @count := 1
    end as CNT
  from Logs, (select @prev := null,@count := null) as t
) as temp
where temp.CNT &gt;= 3

I found this in
https://leetcode-cn.com/problems/consecutive-numbers/comments/
It is really difficult to understand, especially this sentence
(select @prev := null,@count := null) as t

Why can variable declaration be put there?
But it works in leetcode

Yes. This code is syntactically correct, so it does not produce errors. But it is not deterministic -- two executions of it can return different outputs whereas source data is the same. Forget this code. It is non-deterministic - i.e. it is wrong.
The code is processing order-dependent see online demo.  But ORDER BY clause is absent - so the query is wrong.