select t.task_id as counts
from tnm_task_info t
where (t.is_valid = 2 and
to_date(t.start_time, 'yyyy-mm-dd hh24:mi:ss') <= sysdate and
t.start_time is not null)
and (to_date(t.end_time, 'yyyy-mm-dd hh24:mi:ss') >= sysdate and
t.end_time is not null)
and (to_date(t.send_param, 'hh24:mi') <= sysdate and
t.last_update_dt < trunc(sysdate))
and ((t.send_type = 'D' or
(t.send_type = 'M' and t.send_time = to_char(sysdate, 'DD')) or
(t.send_type = 'W' and
t.send_time = to_char(to_number(to_char(sysdate, 'D')) - 1))))
order by t.insert_dt
转载于:https://www.cnblogs.com/xianqingzh/archive/2009/09/21/1570811.html