decode排序应用

2017-01-08  本文已影响0人  Ernest_Chou

将符合条件的排列在前面

select c.*,d.* from hsp.doctor_information d  left join 
 (select opds.doctor_code from PHONE.OUTP_PRESC_DEFAULT_SCHEDULE opds , 
 PHONE.CLINIC_SCHEDULE cs  where opds.clinic_label = cs.clinic_label
  and opds.hsp_config_baseinfo_id = cs.hsp_config_baseinfo_id group by opds.doctor_code ) c
 on d.hsp_staff_baseinfo_id=c.doctor_code
 order by  decode(c.doctor_code,null,9,1) 

尽量用group by 代替 distinct
用decode 、case 排序

上一篇 下一篇

猜你喜欢

热点阅读