Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

using analytical function to calculate concurrency between date range

522382May 5 2008 — edited May 16 2008
Folks,
I'm trying to use analytical functions to come up with a query that gives me the
concurrency of jobs executing between a date range.

For example:
JOB100 - started at 9AM - stopped at 11AM
JOB200 - started at 10AM - stopped at 3PM
JOB300 - started at 12PM - stopped at 2PM

The query would tell me that JOB1 ran with a concurrency of 2 because JOB1 and JOB2
were running started and finished within the same time. JOB2 ran with the concurrency
of 3 because all jobs ran within its start and stop time. The output would look like this.

JOB START STOP CONCURRENCY
=== ==== ==== =========
100 9AM 11AM 2
200 10AM 3PM 3
300 12PM 2PM 2

I've been looking at this post, and this one if very similar...
640412

Here is the sample data..

CREATE TABLE TEST_JOB
( jobid NUMBER,
created_time DATE,
start_time DATE,
stop_time DATE
)
/
insert into TEST_JOB values (100, sysdate -1, to_date('05/04/08 09:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 11:00:00','MM/DD/YY hh24:mi:ss'));
insert into TEST_JOB values (200, sysdate -1, to_date('05/04/08 10:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 13:00:00','MM/DD/YY hh24:mi:ss'));
insert into TEST_JOB values (300, sysdate -1, to_date('05/04/08 12:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 14:00:00','MM/DD/YY hh24:mi:ss'));


select * from test_job;

JOBID|CREATED_TIME |START_TIME |STOP_TIME
----------|--------------|--------------|--------------
100|05/04/08 09:28|05/04/08 09:00|05/04/08 11:00
200|05/04/08 09:28|05/04/08 10:00|05/04/08 13:00
300|05/04/08 09:28|05/04/08 12:00|05/04/08 14:00

Any help with this query would be greatly appreciated.

thanks.
-peter

Comments

SomeoneElse
I don't have an answer, but this is confirmed on 10.2.0.4:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options


SQL> select * from dual model
  2   dimension by(0 as d)
  3   measures(1 as m)
  4   rules(
  5   m[any] = case when not m[1] is present then 1 end);
select * from dual model
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
666352
can you chech you alert trace , may be you can find more details.
SQL> show parameter background_dump_dest;
Hoek
I get:
ops$me%DB>  select * from dual model
  2    dimension by(0 as d)
  3    measures(1 as m)
  4    rules(
  5    m[any] = case when not m[1] is present then 1 end);
 select * from dual model
               *
ERROR at line 1:
ORA-03002: operator not implemented


Elapsed: 00:00:00.03
ops$me%DB> select banner from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - Production
Aketi Jyuuzou
Thankys for replys.

I checked traceFile which is below.
Fri Mar 20 23:22:54 2009
Errors in file d:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_948.trc:
ORA-07445: 例外が検出されました: コア・ダンプ 
[ACCESS_VIOLATION] [_qcss_process_expr+226] [PC:0x1E24A46] [ADDR:0x18] [UNABLE_TO_READ] []
umm I think I will use presentv insted of is present
Solomon Yakobson
Answer
[Bug 6530708|https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_id=6530708&p_database_id=BUG]

SY.
Marked as Answer by Aketi Jyuuzou · Sep 27 2020
Aketi Jyuuzou
Oh thank you,
someday,I will get metaLink accout.
I will see that.
666352
But you can use this code .
 1  select * from dual model
 2   dimension by(0 as d)
 3   measures(1 as m)
 4   rules(
 5*  m[any] = case when  m[1] is present then null else 1 end)
 6  /

        D          M
--------- ----------
        0          1
Laurent Schneider
I created that bug at the time I was writting my chapter on model...

Strangely the error changed in 11.2.0.2
select * from dual model
 dimension by(0 as d)
 measures(1 as m)
 rules(
 m[any] = case when not(m[1] is  present) then 1 end)
              *
Error at line 1
ORA-03002: operator not implemented
Edited by: Laurent Schneider on Jan 13, 2011 11:32 AM

the ORA-3002 was already mentioned, sorry
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 13 2008
Added on May 5 2008
19 comments
4,980 views