1、mysql自定義排序,指定排序輸出:
2、加序號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,"初中","高中", "大專","本科","研究生","未知")
select @rows:=@rows + 1 as rows,pname,***,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')
MySQL自定義排序
select from table where id in 2,3,4,1,5 order by field id,2,3,4,1,5 select from table where id in 2,3,4,1,5 order by field id,2,3,4,1,5 asc select fro...
Mysql自定義排序
mysql自定義排序 最近做專案時碰到乙個排序的問題,資料庫中有乙個字段需要按照 0,1,1 的順序來查詢資料庫。無論是正序還是逆序都滿足不了要求,經過查詢,下面的方法可以滿足要求 select from user order by field status 0,1 1 order by field...
mysql 自定義排序
原表 user id name roleid 1 aaa 1 2 bbb 2 3 ccc 3 4 ddd 4 5 eee 51,mysql可以通過field 函式自定義排序,格式 field value,str1,str2,str3,str4 value與str1 str2 str3 str4比較,...