select *
from (select (select d.dept_name
from tb_sys_loginmsg l, tb_sys_dept d
where l.dept_id = d.dept_id
and l.login_id = z.login_id
and rownum < 2) bz,
(select (select dept_name
from tb_sys_dept
where dept_id = d.super_dept_id)
from tb_sys_loginmsg l, tb_sys_dept d
where l.dept_id = d.dept_id
and l.login_id = z.login_id
and rownum < 2) lc,
z.login_id,
(select l.name
from tb_sys_loginmsg l
where l.login_id = z.login_id) name,
doc.doclevel,
t.recityid,
t.optiontype, --1 新增,2 更新
t.doctitle,
t.docid,
to_char(t.opertime, 'yyyy-mm-dd hh24:mi:ss') opertime,
t.crcityid,
decode((select distinct (kl.cityid)
from kmsdoc_10000logs kl
where kl.docid = t.docid
and kl.username = tb.login_id
and t.recityid = kl.cityid
and kl.clickdate >
to_date('2017-11-14 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
and kl.clickdate <=
to_date('2017-11-15 00:00:00',
'yyyy-mm-dd hh24:mi:ss')),
t.recityid,
'1',
'0') isread,
(select count(0)
from kms_zhidao.iwtrain k
where k.docid = t.docid
and k.userid = z.login_id
and k.cityid = t.reCityid) istrain,
(select count(0)
from kms_workflow_fb_valid tt, kms_workflow_ins_doc_fb fb
where fb.docid = doc.docid
and fb.insid = tt.instanceid
and tt.instime >
to_date('2017-11-14 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and tt.instime <=
to_date('2017-11-15 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and valid_id = 2
and fb.fkcityid = t.recityid) isfk
from kms_zhidao.v_kmsdoc_mark t,
docmark doc,
kms_zhidao.DOCLEVEL_CITY_INFO z,
tb_sys_loginmsg tb
where t.docid = doc.docid
and tb.login_id = z.login_id
--and tb.login_id='zhishiku@01'
and INSTR((select ',' || cityid || ','
from kms_zhidao.DOCLEVEL_CITY_INFO dc
where dc.login_id = tb.login_id),
',' || TRIM(TO_CHAR(t.reCityid)) || ',') > 0
and INSTR((select ',' || doclevel || ','
from kms_zhidao.DOCLEVEL_CITY_INFO dc
where dc.login_id = tb.login_id),
',' || TRIM(TO_CHAR(doc.doclevel)) || ',') > 0
and doc.doclevel <> 1
and t.opertime >
to_date('2017-11-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and t.opertime <=
to_date('2017-11-23 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
order by t.opertime desc, doc.doclevel desc, t.doctitle)
from (select (select d.dept_name
from tb_sys_loginmsg l, tb_sys_dept d
where l.dept_id = d.dept_id
and l.login_id = z.login_id
and rownum < 2) bz,
(select (select dept_name
from tb_sys_dept
where dept_id = d.super_dept_id)
from tb_sys_loginmsg l, tb_sys_dept d
where l.dept_id = d.dept_id
and l.login_id = z.login_id
and rownum < 2) lc,
z.login_id,
(select l.name
from tb_sys_loginmsg l
where l.login_id = z.login_id) name,
doc.doclevel,
t.recityid,
t.optiontype, --1 新增,2 更新
t.doctitle,
t.docid,
to_char(t.opertime, 'yyyy-mm-dd hh24:mi:ss') opertime,
t.crcityid,
decode((select distinct (kl.cityid)
from kmsdoc_10000logs kl
where kl.docid = t.docid
and kl.username = tb.login_id
and t.recityid = kl.cityid
and kl.clickdate >
to_date('2017-11-14 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
and kl.clickdate <=
to_date('2017-11-15 00:00:00',
'yyyy-mm-dd hh24:mi:ss')),
t.recityid,
'1',
'0') isread,
(select count(0)
from kms_zhidao.iwtrain k
where k.docid = t.docid
and k.userid = z.login_id
and k.cityid = t.reCityid) istrain,
(select count(0)
from kms_workflow_fb_valid tt, kms_workflow_ins_doc_fb fb
where fb.docid = doc.docid
and fb.insid = tt.instanceid
and tt.instime >
to_date('2017-11-14 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and tt.instime <=
to_date('2017-11-15 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and valid_id = 2
and fb.fkcityid = t.recityid) isfk
from kms_zhidao.v_kmsdoc_mark t,
docmark doc,
kms_zhidao.DOCLEVEL_CITY_INFO z,
tb_sys_loginmsg tb
where t.docid = doc.docid
and tb.login_id = z.login_id
--and tb.login_id='zhishiku@01'
and INSTR((select ',' || cityid || ','
from kms_zhidao.DOCLEVEL_CITY_INFO dc
where dc.login_id = tb.login_id),
',' || TRIM(TO_CHAR(t.reCityid)) || ',') > 0
and INSTR((select ',' || doclevel || ','
from kms_zhidao.DOCLEVEL_CITY_INFO dc
where dc.login_id = tb.login_id),
',' || TRIM(TO_CHAR(doc.doclevel)) || ',') > 0
and doc.doclevel <> 1
and t.opertime >
to_date('2017-11-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and t.opertime <=
to_date('2017-11-23 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
order by t.opertime desc, doc.doclevel desc, t.doctitle)
