2016-03-29 5 views

答えて

0

使用変数:

SELECT CarId, 
      @seq := IF(@cid = CarId, @seq, 
        IF(@cid := CarId, @seq + 1, @seq + 1)) AS car_id 
    FROM mytable 
    CROSS JOIN (SELECT @seq := 0, @cid := 0) AS vars 
    ORDER BY CarId 

Demo here

関連する問題