Rank

Select id,name,branch_id FROM tb_line WHERE status = 1 and id != 0 and id in () ORDER BY branch_id ASC,id ASC