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.
Installation is successful, but https://localhost:5500/em/ doesn't work. What is wrong?
create table Ex3 (DateVal primary key) as select date '2009-09-01' from dual union select date '2009-10-01' from dual union select date '2009-12-01' from dual union select date '2010-01-01' from dual union select date '2010-02-01' from dual union select date '2010-04-01' from dual; select min(DateVal),max(DateVal),count(*) from (select DateVal, extract(year from DateVal)*12 +extract(month from DateVal) -Row_Number() over(order by DateVal) as disTance from Ex3) group by disTance order by min(DateVal); MIN(DATE MAX(DATE COUNT(*) -------- -------- ---------- 09-09-01 09-10-01 2 09-12-01 10-02-01 3 10-04-01 10-04-01 1
create table Ex4 (ID,Val,SortKey) as select 1, 5, 1 from dual union all select 1,10, 2 from dual union all select 2, 2, 3 from dual union all select 2, 5, 4 from dual union all select 1,15, 5 from dual union all select 3,25, 6 from dual union all select 3,10, 7 from dual union all select 3, 5, 8 from dual union all select 3,15, 9 from dual union all select 4, 5,10 from dual; select ID,min(Val),max(Val),count(*) from (select ID,Val,SortKey, Row_Number() over(order by SortKey) -Row_Number() over(partition by ID order by SortKey) as disTance from Ex4) group by ID,disTance order by min(SortKey); ID MIN(VAL) MAX(VAL) COUNT(*) -- -------- -------- -------- 1 5 10 2 2 2 5 2 1 15 15 1 3 5 25 4 4 5 5 1
create table mytable (sortKey,Val1,Val2) as select 1,'A','X' from dual union all select 2,'A','X' from dual union all select 3,'B','Y' from dual union all select 4,'B','Y' from dual union all select 5,'A','X' from dual union all select 5,'B','X' from dual union all select 6,'A','Y' from dual union all select 7,'B','Y' from dual union all select 7,'A','Y' from dual union all select 8,'A','Y' from dual; select Val1,Val2,min(sortKey) as sta,max(sortKey) as end from (select sortKey,Val1,Val2, dense_rank() over(order by sortKey) -Row_Number() over(partition by Val1,Val2 order by sortKey) as distance from mytable) group by Val1,Val2,distance order by min(sortKey); Val1 Val2 sta end ---- ---- --- --- A X 1 2 B Y 3 4 B X 5 5 A X 5 5 A Y 6 8 B Y 7 7
WITH A AS ( SELECT 1 ID,5 Val, to_date('2009-08-24','yyyy-mm-dd') StartWeek, to_date('2009-08-30','yyyy-mm-dd') EndWeek FROM dual UNION ALL SELECT 1,10, to_date('2009-08-31','yyyy-mm-dd'), to_date('2009-09-06','yyyy-mm-dd') FROM dual UNION ALL SELECT 1,2, to_date('2009-09-07','yyyy-mm-dd'), to_date('2009-09-13','yyyy-mm-dd') FROM dual UNION ALL SELECT 2,2, to_date('2009-09-07','yyyy-mm-dd'), to_date('2009-09-13','yyyy-mm-dd') FROM dual UNION ALL SELECT 2,5, to_date('2009-09-14','yyyy-mm-dd'), to_date('2009-09-20','yyyy-mm-dd') FROM dual UNION ALL SELECT 3,5, to_date('2009-09-14','yyyy-mm-dd'), to_date('2009-09-20','yyyy-mm-dd') FROM dual UNION ALL SELECT 1,15, to_date('2009-09-21','yyyy-mm-dd'), to_date('2009-09-27','yyyy-mm-dd') FROM dual UNION ALL SELECT 3,25, to_date('2009-09-28','yyyy-mm-dd'), to_date('2009-10-04','yyyy-mm-dd') FROM dual UNION ALL SELECT 3,10, to_date('2009-10-05','yyyy-mm-dd'), to_date('2009-10-11','yyyy-mm-dd') FROM dual UNION ALL SELECT 3,5, to_date('2009-10-12','yyyy-mm-dd'), to_date('2009-10-18','yyyy-mm-dd') FROM dual UNION ALL SELECT 3,15, to_date('2009-10-19','yyyy-mm-dd'), to_date('2009-10-25','yyyy-mm-dd') FROM dual UNION ALL SELECT 4,5, to_date('2009-10-26','yyyy-mm-dd'), to_date('2009-11-01','yyyy-mm-dd') FROM dual) , B AS ( SELECT ID, Val, StartWeek, EndWeek, (Row_Number() over(ORDER BY StartWeek) - Row_Number() over(partition BY ID ORDER BY StartWeek)) AS makeGroup FROM A) SELECT ID, SUM(Val) AS SumVal, MIN(StartWeek), MAX(EndWeek) FROM B GROUP BY ID,makeGroup ORDER BY MIN(StartWeek); ID SumVAL MIN(STARTWEEK) MAX(ENDWEEK) 1 17 8/24/2009 9/13/2009 2 7 9/7/2009 9/20/2009 3 5 9/14/2009 9/20/2009 1 15 9/21/2009 9/27/2009 3 55 9/28/2009 10/25/2009 4 5 10/26/2009 11/1/2009
Num Row Distance (Num-Row) === === ============= 2 1 1 3 2 1 4 3 1 5 4 1 6 5 1 7 6 1 12 7 5 13 8 5 14 9 5 15 10 5 16 11 5 17 12 5 20 13 7 21 14 7 etc ...
SQL> select min(CONNECT_BY_ROOT NUMVAL) minval, NUMVAL maxval, max(NUMVAL-CONNECT_BY_ROOT NUMVAL+1) countval 2 from ex1 3 where connect_by_isleaf=1 4 connect by numval=prior numval+1 5 group by numval 6 order by 1; MINVAL MAXVAL COUNTVAL ---------- ---------- ---------- 1 3 3 5 7 3 10 12 3 20 21 2
select min(CONNECT_BY_ROOT NUMVAL) minval, NUMVAL maxval, max(Level) countval from ex1 where connect_by_isleaf=1 connect by numval=prior numval+1 group by numval order by minval; MINVAL MAXVAL COUNTVAL ------ ------ -------- 1 3 3 5 7 3 10 12 3 20 21 2
select min(NumVal),max(NumVal),count(*) from (select NumVal, sum(willSum) over(order by NumVal) as GID from (select NumVal, case when NumVal-1 = Lag(NumVal) over(order by NumVal) then 0 else 1 end as willSum from Ex1)) group by GID order by GID; MIN(NUMVAL) MAX(NUMVAL) COUNT(*) ----------- ----------- --------- 1 3 3 5 7 3 10 12 3 20 21 2
30-JULY-2010 05:10:00 30-JULY-2010 05:50:00 30-JULY-2010 06:55:00 30-JULY-2010 07:54:00 30-JULY-2010 08:58:00
30-JULY-2010 05:10:00 1 30-JULY-2010 05:50:00 1 30-JULY-2010 06:55:00 2 30-JULY-2010 07:54:00 2 30-JULY-2010 08:58:00 3
with t(Val) as( select to_date('20100630 05:10:00','yyyymmdd hh24:mi:ss') from dual union select to_date('20100630 05:50:00','yyyymmdd hh24:mi:ss') from dual union select to_date('20100630 06:55:00','yyyymmdd hh24:mi:ss') from dual union select to_date('20100630 07:54:00','yyyymmdd hh24:mi:ss') from dual union select to_date('20100630 08:58:00','yyyymmdd hh24:mi:ss') from dual) select to_char(Val,'yyyymmdd hh24:mi:ss') as Val, sum(willSum) over(order by Val) as GID from (select Val, case when Lag(Val) over(order by Val) + InterVal '1' hour > Val then 0 else 1 end as willSum from t) order by Val; VAL GID ----------------- --- 20100630 05:10:00 1 20100630 05:50:00 1 20100630 06:55:00 2 20100630 07:54:00 2 20100630 08:58:00 3
SQL> create table t1 (x date, y int, id int) ; Table created. SQL> insert into t1 values (to_date('10/06/2008 03:34:40 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 03:34:30 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 03:34:50 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 04:28:30 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 04:29:30 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 04:30:30 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 04:30:29 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 04:27:35 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 12, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 03:33:34 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 21, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/06/2008 03:34:15 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 228) 2 / 1 row created. SQL> insert into t1 values (to_date('10/07/2008 12:59:40 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 229) 2 / 1 row created. SQL> insert into t1 values (to_date('10/07/2008 12:59:50 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 229) 2 / 1 row created. SQL> insert into t1 values (to_date('10/07/2008 01:00:05 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 229) 2 / 1 row created. SQL> insert into t1 values (to_date('10/07/2008 01:00:30 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 229) 2 / 1 row created. SQL> insert into t1 values (to_date('10/07/2008 01:00:49 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 229) 2 / 1 row created. SQL> insert into t1 values (to_date('10/07/2008 01:00:55 PM', 'MM/DD/YYYY HH12:MI:SS AM'), 10, 229) 2 / 1 row created. SQL> commit ; Commit complete. SQL> select id, x, y, row_number() over (partition by id order by x) rn from t1 order by id, x 2 / ID X Y RN ---------- -------------------- ---------- ---------- 228 06-OCT-2008 15:33:34 21 1 228 06-OCT-2008 15:34:15 10 2 228 06-OCT-2008 15:34:30 10 3 228 06-OCT-2008 15:34:40 10 4 228 06-OCT-2008 15:34:50 10 5 228 06-OCT-2008 16:27:35 12 6 228 06-OCT-2008 16:28:30 10 7 228 06-OCT-2008 16:29:30 10 8 228 06-OCT-2008 16:30:29 10 9 228 06-OCT-2008 16:30:30 10 10 229 07-OCT-2008 12:59:40 10 1 229 07-OCT-2008 12:59:50 10 2 229 07-OCT-2008 13:00:05 10 3 229 07-OCT-2008 13:00:30 10 4 229 07-OCT-2008 13:00:49 10 5 229 07-OCT-2008 13:00:55 10 6 16 rows selected.
ID X Y ---------- -------------------- ---------- 228 06-OCT-2008 15:33:34 21 228 06-OCT-2008 15:34:40 10 228 06-OCT-2008 16:27:35 12 228 06-OCT-2008 16:29:30 10 228 06-OCT-2008 16:30:30 10 229 07-OCT-2008 12:59:40 10 229 07-OCT-2008 13:00:49 10
with t(Val) as( select to_date('10/06/2008 03:34:40', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 03:34:30', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 03:34:50', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 04:28:30', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 04:29:30', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 04:30:30', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 04:30:29', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 04:27:35', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 03:33:34', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/06/2008 03:34:15', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/07/2008 12:59:40', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/07/2008 12:59:50', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/07/2008 13:00:05', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/07/2008 13:00:30', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/07/2008 13:00:49', 'MM/DD/YYYY HH24:MI:SS') from dual union select to_date('10/07/2008 13:00:55', 'MM/DD/YYYY HH24:MI:SS') from dual) select to_char(Val,'yyyy-mm-dd hh24:mi:ss') as Val from (select Val,min(Val) over() as startVal, min(Val) over(order by Val range between InterVal '1' minute following and unbounded following) as nextVal from t) start with Val = startVal connect by prior nextVal = Val; VAL ------------------- 2008-10-06 03:33:34 2008-10-06 03:34:40 2008-10-06 04:27:35 2008-10-06 04:29:30 2008-10-06 04:30:30 2008-10-07 12:59:40 2008-10-07 13:00:49
SQL> select * from table(dbms_xplan.display_cursor) ; PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------------- SQL_ID 9skznz4u401t1, child number 0 ------------------------------------- select id,x,y from (select id,x,y,min(x) over (partition by id) startx, min(x) over (partition by id order by x range between interval '1' minute following and unbounded following) nextval from t1) start with x = startx connect by prior nextval = x Plan hash value: 775368986 ---------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 4 (100)| | |* 1 | CONNECT BY WITH FILTERING| | | | | | |* 2 | VIEW | | 16 | 1136 | 4 (25)| 00:00:01 | | 3 | WINDOW SORT | | 16 | 240 | 4 (25)| 00:00:01 | | 4 | TABLE ACCESS FULL | T1 | 16 | 240 | 3 (0)| 00:00:01 | |* 5 | HASH JOIN | | | | | | | 6 | CONNECT BY PUMP | | | | | | | 7 | VIEW | | 16 | 704 | 4 (25)| 00:00:01 | | 8 | WINDOW SORT | | 16 | 240 | 4 (25)| 00:00:01 | | 9 | TABLE ACCESS FULL | T1 | 16 | 240 | 3 (0)| 00:00:01 | ---------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("X"=PRIOR NULL) 2 - filter("X"="STARTX") 5 - access("X"=PRIOR NULL)