Etbin wrote:No,it is not about requirement..
That doesn't cover the period 0 - 7 am. Let's leave to the OP to decide.
trunc(begindttm) +31 / 24 will lead to nex day.. That will also not cover 0-7AM, since your LHS is begindttm
and begindttm between trunc(begindttm) + 21 / 24 and trunc(begindttm) +31 / 24
select prcstype ,prcsname ,prcsinstance ,runcntlid ,dbname ,oprid ,runstatus ,begindttm ,enddttm --,to_number(to_char(enddttm,'DDMMYYHH24MMSS') )- to_number(to_char(begindttm,'DDMMYYHH24MMSS')) duration ,(enddttm-begindttm)*(24*60*60) as duration_seconds from psprcsrqst where oprid='user1' and begindttm >= trunc(begindtdm)+(21/24) and enddttm <= trunc(begindttm)+(31/24);