select id,serial_group_id,state from ap_model order by serial_group_id asc, ( case when state=1 then 1 when state=2 then 2 when state=-1 then 3 when state=3 then 4 when state=0 then 5 else 99 end )
select id,serial_group_id,state from ap_model order by serial_group_id asc, ( case when state=1 then 1 when state=2 then 2 when state=-1 then 3 when state=3 then 4 when state=0 then 5 else 99 end )