oracle怎么自定义两个字段的排序呢?

两个decode怎么运行呢?

DECODE(AA,'A','1','B','2','C','3','D','4')DECODE(BB,'D','1','C','2','B','3','A','4')

用户kWEye3931 发布于 2022-1-14 09:48 (编辑于 2022-1-14 09:51)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
shirokoLv6资深互助
发布于2022-1-14 10:22

用逗号连接就行了, 还可以分别设置升序降序

order by DECODE(AA,'A','1','B','2','C','3','D','4') desc,DECODE(BB,'D','1','C','2','B','3','A','4') asc

最佳回答
0
free_zzLv6中级互助
发布于2022-1-14 09:49

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,"初中","高中", "大专","本科","研究生","未知")

最佳回答
0
ColdmanLv6高级互助
发布于2022-1-14 09:54

select 

DECODE(AA,'A','1','B','2','C','3','D','4') px1,

DECODE(BB,'D','1','C','2','B','3','A','4') px2

from 

table

order by px1,px2

  • 4关注人数
  • 383浏览人数
  • 最后回答于:2022-1-14 10:22
    请选择关闭问题的原因
    确定 取消
    返回顶部