select id,name,birthday_year,sex
from table
order by (case when sex='女' then birthday_year -5 else birthday_year end)
from table
order by (case when sex='女' then birthday_year -5 else birthday_year end)
调试欢乐多
from table
order by (case when sex='女' then birthday_year -5 else birthday_year end)