28,406
社区成员
发帖
与我相关
我的任务
分享
create table yearday(
"dt" varchar2(20) not null,
constraint index_yearday_dt primary key(dt)
);
select (case when lnk_cnt=0 then '未出勤' else '出勤' end) 是否出勤, logtime 日期,empid 人员编码 from (
select sum(lnk_cnt) lnk_cnt,logtime,empid from (
select count(*) lnk_cnt,to_char(logtime,'yyyy-mm-dd') logtime,empid from
T2 where empid='loginempid' and to_char(logtime,'mm')>='07' and to_char(logtime,'mm')<'08' group by to_char(logtime,'yyyy-mm-dd'),empid
union all(
select 0 lnk_cnt,dt logtime,'loginempid' empid from yearday where to_char(to_date(dt,'yyyy-mm-dd'))<'2009-08-01' and to_char(to_date(dt,'yyyy-mm-dd'))>='2009-07-01'
)
)
group by starttm,empid
order by starttm