RE: sql that is making my brain hurt

From: Stephens, Chris <chris_stephens_at_admworld.com>
Date: Wed, 20 Feb 2008 10:55:36 -0600
Message-ID: <7070047601C21A4CB387D50AD3661F6E09177907@050EXCHANGE.research.na.admworld.com>


This is exactly what I needed.  

Thank you!  

From: Ghassan Salem [mailto:salem.ghassan_at_gmail.com] Sent: Wednesday, February 20, 2008 10:39 AM To: Stephens, Chris
Cc: oracle-l_at_freelists.org
Subject: Re: sql that is making my brain hurt  

try this
select res_id,
trunc(sysdate)+hr/24
from cal, (select level hr from dual connect by level<25) where
sd<trunc(sd)+(hr+1)/24
and ed>trunc(sd)+hr/24
order by 1,hr;

you may have to tweak the where to get the data exactly as you want (e.g. if the staring date is between 8 and 9, should you get 8 or not?)

rgds

On Wed, Feb 20, 2008 at 4:38 PM, Stephens, Chris <chris_stephens_at_admworld.com> wrote:

I am writing a scheduling application in apex. Resources are reserved by hour. I need a calendar to show when resources are reserved.  

In the 'day view' of that calendar I need the schedule split out by hour.  

Resource_id number

Start_res date

End_res date  

If I have a row like: 1, Jan 01 2008 8am, Jan 01 2008 10am, I need the query to return:  

1, Jan 1 2008 8am

1,Jan 1 2008 9am  

So far I've been unable to come up with the sql. Anybody got a quick answer?    

It is amazing how hard sql seems when you haven't had to write anything of any substance in a long time.  

Thanks!      

CONFIDENTIALITY NOTICE:
This message is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by email reply.  

CONFIDENTIALITY NOTICE:
        This message is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by email reply.

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Feb 20 2008 - 10:55:36 CST

Original text of this message