Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 11th, 2005, 07:44 AM
danielrc15 danielrc15 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 51 danielrc15 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 22 m 18 sec
Reputation Power: 6
Unhappy SQL Question - maybe lead and rank

Hi,

I have a problem, I have the following 2 rows:

Start Date End Date Item Used
10/05/04 10/06/04 A
10/05/04 10/10/04 B

As you can see the usage of items A and B overlap, both items A and B are used at the same time for a while, but the usage of A stops after a while and item B is used on it's own.

I need to be able to get them into the following rows:

Start Date End Date Item Used
10/05/04 10/06/04 A
10/05/04 10/06/04 B
11/06/04 10/10/04 B

So I need to know when B was used without A, and then know when B was used on it's own.

I thought of using lead or rank analytic functions, but I have no idea can anybody help?

Thanks

Daniel
__________________
For everything Oracle - www.oraclehome.co.uk

Reply With Quote
  #2  
Old March 16th, 2005, 12:36 PM
paulh1983 paulh1983 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2004
Posts: 1,255 paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level)paulh1983 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 15 h 14 m
Reputation Power: 18
i can give you a syntax if you like:
[code]select name, month, year, sum(salevalue),
rank() over (order by sum(saleValue) desc) as salesrank
from sale, salesrep, time
where sale.srid = salesrep.srid
and sale.code = time.code
group by name, month, year;

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > SQL Question - maybe lead and rank


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT