Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Verisign Code Signing
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old July 30th, 2004, 04:44 PM
KK2796 KK2796 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 11 KK2796 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 40 sec
Reputation Power: 0
Trouble with writing a query

Ok, here's a doozie that has me completely stumped. I've tried everything I can think of. Here is my data:
Code:
CHECK_POINT  PROCESS
          1   A   
          2   A   
          3   B   
          4   B   
          5   B   
          6   B
          6   C   
          7   B   
         10   A
         11   A
         15   B
         16   B
         16   A
         16   C
         17   B
         17   A
         18   B
         18   A
         19   B
         21   C


I need to group together all rows that which are the same process over consecutive checkpoints.


Desired result set:

Code:
PROCESS START STOP
 A          1    2
 A         10   11
 A         16   18
 B          3    7 
 B         15   19
 C          6    6
 C         16   16
 C         21   21

Reply With Quote
  #2  
Old August 2nd, 2004, 03:35 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Try this
select cp2.checkvalue, cp1.checkid, cp2.checkid
from checkpoint cp1
inner join checkpoint cp2
on cp1.checkvalue = cp2.checkvalue
where cp1.checkid<> cp2.checkid
group by cp1.checkvalue
...
You will have to adjust the inner joins for Oracle's non-ANSII style.
__________________
El éxito consiste en una serie de pequeñas victorias día a día

MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

Reply With Quote
  #3  
Old August 2nd, 2004, 07:31 PM
gamyers gamyers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 14 gamyers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This seems to work.
Check out AskTom.oracle.com for more examples of analytics

create table x (check_point number, process varchar2(1));
insert into x values ( 1,'A');
insert into x values ( 2,'A');
insert into x values (10,'A');
insert into x values (11,'A');
insert into x values (16,'A');
insert into x values (17,'A');
insert into x values (18,'A');

insert into x values ( 3,'B');
insert into x values ( 4,'B');
insert into x values ( 5,'B');
insert into x values ( 6,'B');
insert into x values ( 7,'B');
insert into x values (15,'B');
insert into x values (16,'B');
insert into x values (17,'B');
insert into x values (18,'B');
insert into x values (19,'B');

insert into x values ( 6,'C');
insert into x values (16,'C');
insert into x values (21,'C');

select process, start_cp, check_point from
(select process,
case when lag_cp is null and lead_cp is null then check_point
else lag(check_point) over ( partition by process order by check_point)
end start_cp, check_point, lag_cp, lead_cp
from
(select process, check_point,
decode( lag(check_point) over (partition by process order by check_point),
check_point-1, lag(check_point) over ( partition by process order by check_point)) lag_cp,
decode( lead(check_point) over (partition by process order by check_point),
check_point+1, lead(check_point) over ( partition by process order by check_point)) lead_cp
from x)
where lag_cp is null or lead_cp is null)
where start_cp is not null
and (lag_cp is not null or start_cp = check_point)

Reply With Quote
  #4  
Old August 3rd, 2004, 10:42 AM
KK2796 KK2796 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 11 KK2796 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 40 sec
Reputation Power: 0
Holy cow, that is slick. Just when I think I'm getting the hang of analytics, I see how much I've still got to learn.

Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Trouble with writing a query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway