Re: sql that is making my brain hurt

From: Ghassan Salem <salem.ghassan_at_gmail.com>
Date: Wed, 20 Feb 2008 17:39:25 +0100
Message-ID: <411d50f60802200839n13c57bc8w2a33d8cce3758b18@mail.gmail.com>


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.
>

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

Original text of this message