select
le.inst_id, -- INST_ID NUMBER
le.lenum, -- GROUP# NUMBER
le.lethr, -- THREAD# NUMBER
le.leseq, -- SEQUENCE# NUMBER
decode( -- ISCURRENT VARCHAR2(3)
bitand(le.leflg,8),0,'NO','YES'),
decode( -- CURRENT VARCHAR2(3)
bitand(le.leflg,8),0,'NO','YES'),
to_number(le.lelos) -- FIRST_CHANGE# NUMBER
from
x$kccle le,
x$kccdi di
where
bitand(di.diflg,1)!=0 and le.ledup!=0 and bitand(le.leflg,1)=0 and (to_number(le.lelos)<=to_number(di.difas) or bitand(le.leflg,8)=0)