岁月如灬风 2019-11-05 16:36 采纳率: 0%
浏览 356
已采纳

oracle sql语句问题,帮忙看一下,谢谢了!!!

                 CASE
                  WHEN (select capgrade
                          from tb_tpost_userpost
                         where mpostid = i.mpostid
                           and spostid = i.spostid
                           and idcard = r.idcard) = 1 THEN
                   'Ⅰ级'
                  WHEN (select capgrade
                          from tb_tpost_userpost
                         where mpostid = i.mpostid
                           and spostid = i.spostid
                           and idcard = r.idcard) = 2 THEN
                   'Ⅱ级'
                  WHEN (select capgrade
                          from tb_tpost_userpost
                         where mpostid = i.mpostid
                           and spostid = i.spostid
                           and idcard = r.idcard) = 3 THEN
                   'Ⅲ级'
                  WHEN (select capgrade
                          from tb_tpost_userpost
                         where mpostid = i.mpostid
                           and spostid = i.spostid
                           and idcard = r.idcard) = 4 THEN
                   'Ⅳ级'
                  WHEN (select capgrade
                          from tb_tpost_userpost
                         where mpostid = i.mpostid
                           and spostid = i.spostid
                           and idcard = r.idcard) = 5 THEN
                   'Ⅴ级'
                  ELSE
                   '尚无等级'
                END usercapgrade 

语句太过长了,这个怎么改成外层嵌套一次查询,大佬帮忙看一下,谢谢

  • 写回答

3条回答 默认 最新

  • bj_0163_bj 2019-11-05 16:40
    关注

    为什么写成这样?不知道是不是你想要的
    select case when capgrade=1 then 'I级' when capgrade=2 then 'II级' when …… else '尚无等级' end usercapgrade
    from tb_tpost_userpost
    where mpostid = i.mpostid
    and spostid = i.spostid
    and idcard = r.idcard

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含
  • ¥15 麒麟V10桌面版SP1如何配置bonding