select line_id, line_status, 
       CASE
       WHEN LINE_STATUS='Z' and (select 'X'
              from te_leaseline
              where pre_app_sn=a.app_sn and line_status='A')='X' THEN '非使用中'
       WHEN LINE_STATUS IN ('Z','A','2','5','8') THEN '使用中'
       ELSE '非使用中'
       END as "WBS STATUS"  
from te_leaseline a
 
