select WORKINFO.*
from WORKINFO
WHERE to_char(createdate, 'yyyy') = '2015'
AND WORKINFO.IsValid = 1
AND (completeDate is not null and to_char(completeDate, 'YYYY') = '2015')
and (APPROVALDEPT in (select s.oid
from sysorgan s
where s.parentorganoid = 1
or s.oid = 1) or
dutydeptoid in (select s.oid
from sysorgan s
where s.parentorganoid = 1
or s.oid = 1))
and workStatus >= 1
and isvalid = 1
AND (extend4 = 2 or extend4 is null )
ORDER BY DutyDeptOID ASC, WorkInfoNum DESC
select WORKINFO.*
from WORKINFO
WHERE to_char(createdate, 'yyyy') = '2015'
AND WORKINFO.IsValid = 1
AND (completeDate is not null and to_char(completeDate, 'YYYY') = '2015')
and (APPROVALDEPT in (select s.oid
from sysorgan s
where s.parentorganoid = 1
or s.oid = 1) or
dutydeptoid in (select s.oid
from sysorgan s
where s.parentorganoid = 1
or s.oid = 1))
and workStatus >= 1
and isvalid = 1
AND extend4 = 2 or extend4 is null
ORDER BY DutyDeptOID ASC, WorkInfoNum DESC