Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6672017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:27:31+00:00 2026-05-26T03:27:31+00:00

Hi I’d like to calculate number of batch running instance for a particular time

  • 0

Hi I’d like to calculate number of batch running instance for a particular time slice. For example, I’ve a table:

BatchID startTime   endTime
12957   10:15   10:25
13032   10:16   10:20
13080   10:16   10:22
13090   10:16   10:20
13214   10:19   10:30
13232   10:19   10:22
13276   10:19   10:29
13279   10:19   10:30
13315   10:20   10:23
13341   10:20   10:24
13430   10:22   10:33
13566   10:27   10:30
13580   10:27   10:31
13585   10:28   10:31
13596   10:28   10:32
13626   10:30   10:42
13637   10:32   10:35
13699   10:40   10:44
13702   10:41   10:45

The number of instance running at 10:41 would be 3, and the running batches are: BatchID 13626, 13699 and 13702.

To visualise this problem, I have a chat with a time slice from 10:15 to 10:41 with a step of 1 minutes as the x-axis,and the number of instance running at that time slice as the y-axis. I’m thinking to implement in ORACLE(SQL/PLSQL) or EXCEL(function/VBA/Pivot Table/etc.), what’s your advise?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:27:31+00:00Added an answer on May 26, 2026 at 3:27 am

    Creating your sample table:

    SQL> create table mytable (batchid,starttime,endtime)
      2  as
      3  select 12957, '10:15', '10:25' from dual union all
      4  select 13032, '10:16', '10:20' from dual union all
      5  select 13080, '10:16', '10:22' from dual union all
      6  select 13090, '10:16', '10:20' from dual union all
      7  select 13214, '10:19', '10:30' from dual union all
      8  select 13232, '10:19', '10:22' from dual union all
      9  select 13276, '10:19', '10:29' from dual union all
     10  select 13279, '10:19', '10:30' from dual union all
     11  select 13315, '10:20', '10:23' from dual union all
     12  select 13341, '10:20', '10:24' from dual union all
     13  select 13430, '10:22', '10:33' from dual union all
     14  select 13566, '10:27', '10:30' from dual union all
     15  select 13580, '10:27', '10:31' from dual union all
     16  select 13585, '10:28', '10:31' from dual union all
     17  select 13596, '10:28', '10:32' from dual union all
     18  select 13626, '10:30', '10:42' from dual union all
     19  select 13637, '10:32', '10:35' from dual union all
     20  select 13699, '10:40', '10:44' from dual union all
     21  select 13702, '10:41', '10:45' from dual
     22  /
    
    Table created.
    

    Introducing the start and the end of the interval you want to report on, as bind variables. You can recognize the use of bind variables in SQL and PL/SQL by their leading colons.

    SQL> var START_X_AXIS varchar2(5)
    SQL> var END_X_AXIS varchar2(5)
    SQL> begin
      2    :START_X_AXIS := '10:15';
      3    :END_X_AXIS := '10:41';
      4  end;
      5  /
    
    PL/SQL procedure successfully completed.
    

    And a query that’s executed in three phases for sake of clarity. First transforming your varchar2 times to real dates (advice is to store them like that as well, by the way). The second query shows all minutes on the X-axis for your report. The third one does the counting.

    SQL> with mytable_with_real_dates as
      2  ( select batchid
      3         , to_date(starttime,'hh24:mi') starttime
      4         , to_date(endtime,'hh24:mi') endtime
      5      from mytable
      6  )
      7  , all_minutes as
      8  ( select to_date(:START_X_AXIS,'hh24:mi') + numtodsinterval(level-1,'minute') minute
      9      from dual
     10   connect by level <=  24 * 60 * (to_date(:END_X_AXIS,'hh24:mi') - to_date(:START_X_AXIS,'hh24:mi')) + 1
     11  )
     12  select to_char(m.minute,'hh24:mi')
     13       , count(t.batchid)
     14    from all_minutes m
     15         left outer join mytable_with_real_dates t on (m.minute between t.starttime and t.endtime)
     16   group by m.minute
     17   order by m.minute
     18  /
    
    TO_CH COUNT(T.BATCHID)
    ----- ----------------
    10:15                1
    10:16                4
    10:17                4
    10:18                4
    10:19                8
    10:20               10
    10:21                8
    10:22                9
    10:23                7
    10:24                6
    10:25                5
    10:26                4
    10:27                6
    10:28                8
    10:29                8
    10:30                8
    10:31                5
    10:32                4
    10:33                3
    10:34                2
    10:35                2
    10:36                1
    10:37                1
    10:38                1
    10:39                1
    10:40                2
    10:41                3
    
    27 rows selected.
    

    EDIT: I just saw your comment that your columns are stored as dates. That’s good news, so you can skip the first part and start with line number 7, replacing the comma with the word “WITH”.

    Regards,
    Rob.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have two tables with like below codes: Table: Accounts id | username |
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.