Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would convert this RenewTime to 5 minute intervals like this:</p> <pre><code>((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60 /5 </code></pre> <p>Next, I would use the floor function to distinguish one 5 minute group from another:</p> <pre><code>floor((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60/ 5) </code></pre> <p>Next, I would convert this to the text you want for the RenewalTime column as follows:</p> <pre><code>to_char( 5 * floor((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60/ 5)) ||' - ' || to_char( 5 * (floor((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60/ 5)+1)) </code></pre> <p>The intervals are like this:</p> <p>0 &lt;= renewal_time &lt; 5 ==> '0 - 5'</p> <p>5 &lt;= renewal_time &lt; 10 ==> '5 - 10'</p> <p>10 &lt;= renewal_time &lt; 15 ==> '10 - 15'</p> <p>15 &lt;= renewal_time &lt; 20 ==> '15 - 20'</p> <p>This results in this sql statement.</p> <pre><code>select to_char( 5 * floor((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60/ 5)) || ' - ' || to_char( 5 * (floor((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60/ 5) +1)) RenewalTime count(1) renewal_count from refill, subscription_interval i where trunc(refill_date) &gt; to_date('18-nov-13', 'dd-mon-yy') and (cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60 &gt; 0 and (cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60 &lt; 1000 group by to_char( 5 * floor((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60/ 5)) || ' - ' || to_char( 5 * floor((cast(i.modification_date as date) - cast(refill_date as date)) * 24 * 60/ 5) +1) order by 1; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload