decode排序应用

将符合条件的排列在前面

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 排序

你可能感兴趣的:(decode排序应用)