How to count up rows with duplicate id
Try something like

SELECT @cnt:=CASE WHEN c.id=@id THEN @cnt+1 ELSE 1 END count_t,
       @id:=c.id id, 
       so.trans_id trans_id
FROM (SELECT @id:=0, @cnt:=0) init_vars,
     customer c LEFT JOIN sales_order so ON ...
ORDER BY c.id, so.trans_id;


fiddle