Por favor, revisa mi violín
SELECT id,
crew_id,
amount,
type,
(
CASE type
WHEN @curType
THEN @curRow := @curRow + 1
ELSE @curRow := 1 AND @curType := type END
) + 1 AS rank
FROM Table1 p,
(SELECT @curRow := 0, @curType := '') r
ORDER BY crew_id,type asc;