Incremental column depening on column value
Just found the solution after banging my head into the wall:

SELECT
  t.*,
  @row := IF(@lastState = t.State, @row + 1, 0) as counter,
  @lastFunkt := t.State
FROM
  table t,
  (SELECT @row := 0,
          @lastState := '') SQLVars