-1
select 
    compcode, emplcode, attndate, costcode,
    decode(shiftflg, 'I', readtime) INTIME,
    decode(shiftflg, 'O', readtime) OUTTIME
from
    ecatnrec
where  
    emplcode = 'RF025'
order by 
    emplcode;

在此处输入图像描述

4

1 回答 1

1

您可以使用聚合:

select compcode, emplcode, attndate, costcode,
       max(case when shiftflg = 'I' then readtime end) as INTIME,
       max(case when shiftflg = 'O' then readtime end) as OUTTIME
from ecatnrec
where  emplcode = 'RF025'
group by compcode, emplcode, attndate, costcode
order by emplcode;

这假设group by键的唯一值最多在“I”和一个“O”行上。

于 2018-07-03T10:46:58.333 回答