select t.doctype, t.id from smdocuments t where t.doctype in ('WI', 'WO') and t.createdat between to_date(&DateStart, 'DD.MM.YYYY') and to_date(&DateEnd, 'DD.MM.YYYY') and t.docstate=3
select doctype, id from smdoclog where doctype in ('WI', 'WO') and trunc(eventtime) between to_date(&DateStart, 'DD.MM.YYYY') and to_date(&DateEnd, 'DD.MM.YYYY') and newstate=3 and oldstate<>3