 <p>As you say "correct" to all our assumptions, ...</p> <ul> <li>you only use the time part of rounded_time and we must ignore the date part</li> <li>the batch that shall pick 12:15, 12:30, 12:45, and 13:00 runs after 13:00 and before 14:00</li> </ul> <p>This leads to a WHERE clause like this:</p> <pre><code>where extract(hour from systimestamp) - 1 = extract(hour from cast(rounded_time as timestamp) - interval '1' minute) </code></pre> <p>Here we extract the current hour when the batch is executing the query and subtract one. This would give us 12 for the batch running after 13:00 and before 14:00.</p> <p>And we take rounded_time, subtract a minute to get from 12:00 to 11:59 and from 13:00 to 12:59, and extract the hour. So we get 12 for all records after 12:00 until 13:00.</p> <p>The complete query:</p> <pre><code>select domain, mode, channel, kpi, sum(value), avg(avgtm), to_char(sysdate, 'hh24') || ':00' from t1 where extract(hour from systimestamp) - 1 = extract(hour from cast(rounded_time as timestamp) - interval '1' minute) group by domain, mode, channel, kpi; </code></pre>