1、mysql自定义排序,指定排序输出:
SELECT
CASE WHEN ajj_whcd="" then "未知"
WHEN ajj_whcd IN ("初中", "中学") THEN "初中"
WHEN ajj_whcd IN ("中专","中技","中专(中技)", "中师","技工","技校","普高","职专","职中", "高中","高中?") THEN "高中"
WHEN ajj_whcd IN ("专科", "大专", "大专?", "职高", "大专毕业", "高技", "高职") THEN "大专"
WHEN ajj_whcd IN ("本科","本科?","学士", "理科","函授本科", "大学","大学本科") THEN "本科"
ELSE "研究生" END AS whcd, count(ajj_sfzh)
FROM yw_ajj_saqscjdglj_aqscr
GROUP BY whcd
order by field(whcd,"初中","高中", "大专","本科","研究生","未知")
2、加序号
select @rows:=@rows + 1 as rows,pname,sex,jobtype,education
from tsafe_pxrecords_kpi,(select @rows := 0) r
where str_to_date(concat(certi_end_year,'-',certi_end_month,'-',certi_end_day),'%Y-%m-%d')>=DATE_FORMAT(now(),'%Y-%m-%d')
————————————————