A difficult select

Hi,
I have the following data from a schedule system
begin_time End_time status
============================
9:00 9:30 vacant
9:30 10:00 vacant
10:00 10:30 vacant
10:30 11:00 busy
11:00 11:30 busy
11:30 12:00 vacant
12:00 12:30 busy
12:30 13:00 vacant
how can I write 1 sql to display the busy hours any take the ending time of the resouces so the out put will be:-
begin_time End_time status
============================
10:30 11:30 busy
12:00 12:30 busy
note that 10:30-11:00 and 11:00-11:30 is merged as 1
or alternatively, I could also modify the script to display the vacant hours so that it will be:-
begin_time End_time status
============================
9:00 10:30 vacant
11:30 12:00 vacant
12:30 13:00 vacant
Again note that all the time for 9:00 - 10:30 are merged. But also note that the data is split according to continues availability of the time.
Does any one have any idea to help me to have 1 single sql to do this?
I am using oracle 8.0.5 server, so please don't advice me to use any oracle 9 and above commands.
Thanks

Hi Jonas,
Actually, I am doing a time table system for a college and the followings are some table
SQL> desc RESOURCE_DAY_TIME_SETUP
Name Null? Type
CAMPUS NOT NULL VARCHAR2(40)
RESOURCES_CATEGORIES NOT NULL VARCHAR2(40)
RESOURCES_CODE NOT NULL VARCHAR2(30)
TIME_FROM NOT NULL DATE
TIME_TO NOT NULL DATE
DAY NOT NULL VARCHAR2(10)
COLLEGE_REG_NO NOT NULL VARCHAR2(40)
DAY_CODE NOT NULL NUMBER(1)
TIME_ZONE NOT NULL NUMBER(2)
BUILDING_CODE NOT NULL VARCHAR2(40)
FLOOR_CODE NOT NULL VARCHAR2(40)
CLASS_ZONE NOT NULL NUMBER(2)
CAPACITY NOT NULL NUMBER(5)
SQL> desc RESOURCE_ACTIVITY_MASTER
Name Null? Type
CAMPUS NOT NULL VARCHAR2(40)
RESOURCES_CATEGORIES NOT NULL VARCHAR2(40)
RESOURCES_CODE NOT NULL VARCHAR2(30)
DAY NOT NULL VARCHAR2(10)
TIME_FROM NOT NULL DATE
TIME_TO NOT NULL DATE
ACTIVITY_SUBJECT NOT NULL VARCHAR2(20)
LECTURER_NAME NOT NULL VARCHAR2(30)
REMARKS VARCHAR2(10)
INTAKE_NUMBER NUMBER(10)
SEMESTER_NO NUMBER(5)
PERIOD_FROM NOT NULL DATE
PERIOD_TO NOT NULL DATE
COLLEGE_REG_NO NOT NULL VARCHAR2(40)
COURSE_CODE VARCHAR2(20)
CAPACITY NUMBER(5)
TIME_ZONE NUMBER(2)
DAY_CODE NUMBER(2)
STATUS VARCHAR2(1)
TT_LOCK VARCHAR2(1)
The setup table contains all the timing and the master table contains all the activity.
based on your example, i changed my sql to be:-
SELECT distinct rdts1.BUILDING_CODE Building,
rdts1.DAY,rdts1.RESOURCES_CODE Room,
TO_CHAR(min(rdts1.TIME_FROM), 'HH24:MI') "FROM",
TO_CHAR(rdts2.TIME_TO,'HH24:MI') "TO"
FROM RESOURCE_DAY_TIME_SETUP rdts1,RESOURCE_DAY_TIME_SETUP rdts2, RESOURCE_ACTIVITY_MASTER
WHERE RESOURCE_ACTIVITY_MASTER.CAMPUS(+) = rdts1.CAMPUS
AND rdts1.CAMPUS LIKE 'KL CAMPUS'
AND RESOURCE_ACTIVITY_MASTER.COLLEGE_REG_NO(+) LIKE '177263-T'
AND RESOURCE_ACTIVITY_MASTER.DAY(+) = rdts1.DAY
AND rdts1.DAY LIKE TO_CHAR(sysdate, 'DY')
AND RESOURCE_ACTIVITY_MASTER.RESOURCES_CODE(+) = rdts1.RESOURCES_CODE
AND TO_CHAR(RESOURCE_ACTIVITY_MASTER.TIME_FROM(+), 'HH24:MI') = TO_CHAR(rdts1.TIME_FROM, 'HH24:MI')
AND TO_CHAR(RESOURCE_ACTIVITY_MASTER.TIME_TO(+), 'HH24:MI') = TO_CHAR(rdts1.TIME_TO, 'HH24:MI')
AND RESOURCE_ACTIVITY_MASTER.PERIOD_FROM(+) <= sysdate
AND RESOURCE_ACTIVITY_MASTER.PERIOD_TO(+) >= sysdate
and resource_activity_master.status(+) like 'N'
and nvl(RESOURCE_ACTIVITY_MASTER.CAMPUS,'x') = 'x'
and exists
(select 'x' from RESOURCE_DAY_TIME_SETUP rdts3
where to_char((rdts3.time_from),'HH24:mi') > to_char((rdts1.time_from),'HH24:mi')
and not nvl(rdts1.campus,'x') = nvl(rdts3.campus,'x')
having TO_CHAR(rdts2.TIME_FROM, 'HH24:MI') = to_char(min(rdts3.time_from),'HH24:mi') )
and rdts1.RESOURCES_CODE = '2.04'
group by rdts2.TIME_TO, rdts1.BUILDING_CODE, rdts1.DAY,rdts1.RESOURCES_CODE
ORDER BY rdts1.BUILDING_CODE,
rdts1.DAY,
rdts1.RESOURCES_CODE,
TO_CHAR(min(rdts1.TIME_FROM), 'HH24:MI'),
TO_CHAR(rdts2.TIME_TO, 'HH24:MI')
and it is taking hours and yet the result comes out...
Any advices pls.
Thank you

Similar Messages

  • Difficult selection - help needed

    I'm attaching an image where the client has requested the dark background be made a bright color, #e48da8 for example, yet still have a believable edge from hair to background. I have made a couple of attempts which have fallen short. How can I replace that darkness with a brightish color and do it convincingly, given that the darkness comes into the hair quite a bit, and the edge is feathery?

    After selecting as much as you can with the magic wand, open the refine edge dialog ... and after the job done in it, there is a section at the bottom of the dialog "decontaminate colors", select it and adjust the slider. You can find some nice video tutorials on the net about refining edges.
    And, for the dark portion of the hair ... I tried it again ... hue/saturation adjustment layer may be more useful than the dodge technique (for there is a blue shine from the original background). Lower the lightness slider a little and apply a mask to the adjustment layer.

  • Selecting objects.

    I have multiple objects on a slide and I need a way to see all objects in a list so that I can select the one I'm interested in modifying. If the objects have animation applied to it then it's not a problem, but when objects do not have animation applied then it's difficult select objects behind other objects. Sure you can use shift click but when you have more than 2 objects then that doesn't work. Can someone help with this please?

    Thanks, that was most helpful and essentially solved my problem except that I would be nice if there was a window with a list of the items on the slide.

  • How to find from the data dict if a user has read access on a directory

    How to find "dynamically" if a user has READ access to a directory object.
    I want to know if there is a data dictionary table that holds if a user/schema has read access to a directory object.
    I know there is an dba_directories table and an all_directories table but they dont give information as to which user has read access granted to the directory.

    Not so difficult.
    select  'YES'
       from all_tab_privs A, all_directories B
       where a.grantee = 'USERNAME'
           and a.table_name = b.directory_name
           and b.directory_path = 'PATH YOU ARE LOOKING FOR'
    How to find "dynamically" if a user has READ access to a directory object.
    I want to know if there is a data dictionary table that holds if a user/schema has read access to a directory object.
    I know there is an dba_directories table and an all_directories table but they dont give information as to which user has read access granted to the directory.

  • Forms won't do order by after the formula columns or constants in union all

    i have a big select as :
    select * from
    ( select .....,id doc_id, '1' op from .....
    union all
    select ......., id doc_id, '2' op from .....
    union all
    select ......., id doc_id, '3' op from .....
    ) order by id, op
    where i can have the same id for a number x >1 rows with diffrent values for op.
    lets say 5 rows with values id plus 1,2,1,2,3 for op.
    In a program unit i have a cursor with this select and i fetch every row and write them in a text file type .csv.
    The problems are :
    1) it won't do the order by after op ,
    i say order by id, op but the result is only ordered after id
    ... id op
    ... 1 2
    ... 1 1
    .... 1 2
    2)
    if i modify the select like this :
    select ...., id, op from ---i put the aliases here instead of *
    ( select .....,id doc_id, '1' op from .....
    union all
    select ......., id doc_id, '2' op from .....
    union all
    select ......., id doc_id, '3' op from .....
    ) order by id, op
    in the csv the column op in empty , so i only get the id information
    ... id op
    ... 1
    ... 1
    .... 2
    Any idea ?
    Oh and my screen goes white , the form block sometimes when i have a "difficult "
    select but after a while i get the result i wanted (message or csv file)

    select * from
    ( select .....,id doc_id, '1' op from .....
    union all
    select ......., id doc_id, '2' op from .....
    union all
    select ......., id doc_id, '3' op from .....
    ) order by id, op
    The problems are :
    1) it won't do the order by after op ,
    i say order by id, op but the result is only ordered after id
    select * from
    ( select .....,id doc_id, '1' op from .....
    union all
    select ......., id doc_id, '2' op from .....
    union all
    select ......., id doc_id, '3' op from .....
    ) order by 3,4
    if[u] id is 3 column positions, and '1' op is 4 column positions in UNION-SELECT
    Hope this helps

  • 3 x 3 diggits on pink background :) please help

    some how (i think in about:config :-( ) i run some feature and have in all input box and in left upper corner 3 numbers on pink background, please help me with this. What this is?
    On change of selector it changes numbers but for what this is i don't know :/
    how to disable it becuse is difficult select first entry ?
    Sorry for my english, is rather bad. ( im from poland )
    Big thanks and regards

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    *Use a compressed image type like PNG or JPG to save the screenshot
    *Make sure that you do not exceed the maximum size of 1 MB
    Missing icons are usually supplied by a font that is downloaded from the server (@font-face) as you might see by little boxes that show the hex code of the characters instead.
    Make sure that you allow pages to choose their own fonts.
    *Tools > Options > Content : Fonts & Colors > Advanced: [X] "Allow pages to choose their own fonts, instead of my selections above"
    You can check the <b>gfx.downloadable_fonts.enabled</b> pref on the <b>about:config</b> page and make sure that it is set to true (if necessary double-click the line to toggle its value).

  • Cs6 or cs4 ?

    what is the better cs6 or cs4 ?

    I'll summarize important differences:
    Content Aware Fill —  a massively useful tool that works magic seamlessly removing unwanted image elements.
    Content Aware Move — select and object and drag to another part of the image.  Photoshop seamlessly blends into the new position, and fixes where the object used to be.  It's like magic.
    Refine Edge — another hugely important tool that revolutionized the speed and accuracy of making difficult selections. 
    Puppet Warp — Kind of like it sounds.  reposition the angle of a person's arms, for instance.
    Better nicer interface.
    Video editing; a ton of what Adobe call JDI (Just Do it) features which are individually minor, but together speed up your workflow.  Loads more that you can read for yourself in the link above.
    Or just keep reading through to CC2014 and see why you should get a Creative Cloud subscription.
    I do hope you were not trolling after typing all that!

  • How do you change the minus symbol on the quick selection tool to a plus symbol? im finding it difficult to select an area.

    how do you change the minus symbol on the quick selection tool to a plus symbol? im finding it difficult to select an area.

    You can use the Alt/Option key to toggle between add + and subtract -
    http://helpx.adobe.com/photoshop/using/making-quick-selections.html
    First though select the Add to Selection in the tool options bar for that to work.

  • Selecting Difficult Shapes - Refine Edge Tool

    In Elements 11 it was announced that selecting difficult shapes like hair for cutting out people etc was a new feature.  I could find no guidance on how to do it in the program help or online.
    I actually now know how to do it now because I have a tutorial from Digital Photo Magazine, but there needs to be guidance available on this new feature for anyone else who wants to use it.  It didnt feature in the new guided edits or "How To" videos (Why not?)
    Mike Grantham

    Thanks Jon, it does give some guidance but isnt as good as the excellent guidance given in the UK Digital Photo Magazine CD in August 2012.  Hunting around, I did find http://download.photoshopelementsuser.com/LC/LearningCenter11/LC11-RefineEdge.mov which is clearer, although in this case it shows selecting the background, not the person (just select the person if you want to cut them out instead).  In the DP magazine it suggested doing a reasonably precise cut out with the polygonal lasso tool, doing the best you can around hair, then refining it with the refine edge brush.  The results are excellent!
    My main reason for posting this was to get Adobe to put something in help on this topic.  What good is it introducing a new feature in Elements then giving absolutely no guidance on how it works?!

  • When I select a menu item, the highlight is light blue and the item font color goes white. It is very difficult to read? Any solution?

    When I select Bookmarks, the menu item (Bookmarks) is highlighted in light gray color; and the letters of the work itself (Bookmarks) turns white. This same thing happens when you go into individual bookmark selections. It is very difficult to read. Are there any alternatives that can be set by the user?

    Are you using a standard Windows theme?
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • Font selection difficult

    In both Premier Pro and Encore, it is difficult to select a font because I can't scroll the list with my mouse wheel and if I select a font and want to try another, I have to start from the top again and move slowly downthe list, which isn't in Alphabetical order.  The following video shows this, first items not in Alphebetci order then selecting and starting again. Is there an easier way to do this?  Thank you.

    Thanks for the reply Tom. I went in to font book and checked for any corrupted fonts. Font book found a few fonts that threw out a 'caution'. I then deleted them.
    I installed the most recent release of Final Cut, restarted,  then created a new title graphic and have found the issue still exists.
    Any other possible fixes?

  • I am having a difficult time getting the duration of multiple selected clips. The duration display only will display the time for one clip.  Yes, I know I can add them up myself, but why?  :-)

    I am having a difficult time getting the duration of multiple selected clips. The duration display will only display the time for one clip not multiple clips.  Yes, I know I can add them up myself, but why?  :-)
    I am using imovie 10.0.6

    For reasons that you would have to ask Apple for they decided not to allow the precise position of the playhead to be shown in iMovie 10 (unlike in FCP 10.1.x).
    Geoff

  • Cursor flickers so badly that it is very difficult to select ANYTHING

    On every web page, the cursor flickers on and off so badly that it is difficult and sometimes impossible to select anything - button, checkbox, whatever.
    And, with reference to the pasted information below, I did not change or update any preferences. I simply had 2 add-ons disabled at installation of the new version of the browser.

    Does the issue still occur if you start Firefox in Safe Mode? http://support.mozilla.com/en-US/kb/Safe+Mode
    How about with a new, empty profile? http://support.mozilla.com/en-US/kb/Basic%20Troubleshooting#w_8-make-a-new-profile

  • The printing on the web page overlap, making it difficult to make a selection

    The script lines on web pages overlap.

    Reset the page zoom on websites that look wrong: "View > Zoom > Reset" (Ctrl + 0 (zero))<br />
    See http://kb.mozillazine.org/Zoom_text_of_web_pages
    If you increased the minimum font size then try a lower setting (default is none) as a too high value can cause issues like you described.
    * Tools > Options > Content : Fonts & Colors: Advanced > Minimum Font Size
    * Tools > Options > Content : Fonts & Colors: Advanced > "Allow pages to choose their own fonts, instead of my selections above"
    See also [[Websites look wrong]]
    Other things that need attention.<br>
    See http://www.mozilla.com/plugincheck/
    Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
    *Shockwave Flash 10.0 r42
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/

  • Switched from Samsung Note 2 to iphone 6. Faced Difficulties while sending message. [1]Multiple Selection of receipients is not available. Eg. If I click plus, it shows me all the contacts but i cannot select multiple contacts using checkbox

    Phone : IPhone 6
    OS : 8.1
    Problem Statement : Multiple Selection of Recipients while drafting New Message in SMS.
    Expected Solution : Checkbox should have been provided to select multiple contacts using one screen

    Thanks for the reply.. I also tried that way.. I face couple of issues
    1) I could not find an option of saving a Draft Message
    2) After multiple recipients(I have selected 12 recipients) in "TO" section, if I type a word in "TO" such as "Pre", it shows me all the contacts containing "Pre"  but I cannot select the last contact incase there are more than 20 contacts coz I am unable to scroll down till the end.. If I do so.. I cannot select coz screen scrolls up automatically..
    Pls try ... If required I will insert video

Maybe you are looking for