sort case when
case when inq.urgent_flag=1 and urgeCount=2 then @sort:=99 when inq.urgent_flag=1 and urgeCount=1 then @sort:=97 when inq.urgent_flag=1 and urgeCount=0 then @sort:=95 when inq.urgent_flag=0 and urgeCount=2 then @sort:=93 when inq.urgent_flag=0 and urgeCount=1 then @sort:=91 else @sort:=87 end as sort ORDER BY res.sort