kmswilliam
2020-12-25 11:52
采纳率: 100%
浏览 113

SQL 语句中 case when 的优化

select t.FD_INDEXNAME 名称,
       t.FD_SCORE 得分,
       t.FD_INDEXVALUE 档位,
       case 
       when  t.FD_SCORE = (select max(n.FD_SCORE) from ns_assets_indexes n where n.FD_STEPID in (select fd_id from ns_assets_step s where s.fd_rateid = '098266ca-5e83-48f4-ae44-99fbf2df57a3')
         and n.FD_INDEXCATEGORY = '保值性' and n.fd_indexname != '保值性') then  t.FD_QUALITATIVE_OPTIONS
       when  t.FD_SCORE = (select min(n.FD_SCORE) from ns_assets_indexes n where n.FD_STEPID in (select fd_id from ns_assets_step s where s.fd_rateid = '098266ca-5e83-48f4-ae44-99fbf2df57a3')
         and n.FD_INDEXCATEGORY = '保值性' and n.fd_indexname != '保值性') then  t.FD_QUALITATIVE_OPTIONS
       end 描述
 from(
       select n.FD_INDEXNAME,
              n.FD_SCORE,
              n.FD_INDEXVALUE,
              n.FD_QUALITATIVE_OPTIONS
          from ns_assets_indexes n
         where n.FD_STEPID in
               (select fd_id
                  from ns_assets_step s
                 where s.fd_rateid = '098266ca-5e83-48f4-ae44-99fbf2df57a3')
         and n.FD_INDEXCATEGORY = '保值性'
         and n.fd_indexname != '保值性') t

2条回答 默认 最新

相关推荐 更多相似问题