Count booking question

Hello in a booking table iwth fields
id , room_id , start_date , end_date
i want to find how many days eatch month or in a from to date a room is booked group by room.
Any ideas ?
Regards
Aris

with parameters as
  select to_date('&param_start_date', 'YYYYMMDD') as start_date, to_date('&param_end_date', 'YYYYMMDD') as end_date from dual
booking as
  select 1 as id, 1 as room_id, to_date('20091101', 'YYYYMMDD') as start_date, to_date('20091110', 'YYYYMMDD') as end_date from dual union all
  select 2 as id, 1 as room_id, to_date('20091115', 'YYYYMMDD') as start_date, to_date('20091118', 'YYYYMMDD') as end_date from dual union all
  select 3 as id, 2 as room_id, to_date('20091103', 'YYYYMMDD') as start_date, to_date('20091108', 'YYYYMMDD') as end_date from dual
select booking.room_id,
       sum(least(booking.end_date, parameters.end_date) - greatest(booking.start_date, parameters.start_date) + 1) as days
from booking, parameters
where booking.start_date between parameters.start_date and parameters.end_date
or booking.end_date between parameters.start_date and parameters.end_date
or (booking.start_date < parameters.start_date and booking.end_date > parameters.end_date)
group by booking.room_id
Enter value for param_start_date: 20091101
Enter value for param_end_date: 20091130
old   3:   select to_date('&param_start_date', 'YYYYMMDD') as start_date, to_date('&param_end_date',
new   3:   select to_date('20091101', 'YYYYMMDD') as start_date, to_date('20091130', 'YYYYMMDD') as
   ROOM_ID       DAYS
         1         14
         2          6
SQL> /
Enter value for param_start_date: 20091105
Enter value for param_end_date: 20091109
old   3:   select to_date('&param_start_date', 'YYYYMMDD') as start_date, to_date('&param_end_date',
new   3:   select to_date('20091105', 'YYYYMMDD') as start_date, to_date('20091109', 'YYYYMMDD') as
   ROOM_ID       DAYS
         1          5
         2          4

Similar Messages

  • Address book question

    IS THERE A WAY TO CONDUCT A MAIL MERGE FUNCTION WITH ADDRESS BOOK?
    IF NOT!.......how can I export (only) a Smart Group to excel or Numbers to do so????

    Ran test. It does delete a given address book from the phone if deselected. Thanks.
    >>> [email protected]<[email protected]> 7/9/2014 6:41:AM >>>
    Sorry, wasn't sure which to post in.
    >>> Simon Flood<[email protected]> 7/9/2014 6:02:AM >>>
    On 08/07/2014 18:00, [email protected] wrote:
    > Running Data Synchronizer 1.2.5 Build 299 against GW 8.0.2. If an
    > address book has been selected on the Edit user page in the past and
    > those contacts have been synced to the phone will the system delete them
    > if the address book is de-selected? Will it just ignore the address book
    > going forward?
    > Thanks,
    > Bill
    Duplicate of
    https://forums.novell.com/showthread...-Book-Question
    Please do not post the same issue to multiple forums as it splits
    support efforts and doesn't help others.
    Simon
    Novell Knowledge Partner
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below. Thanks.

  • Parent - child table issue wrt to count - SQL question

    I have a scenario:
    There are 2 tables (parent and child). lets say, case summary table and task level dimension table.
    for every case id in case summary table, there would be multiple tasks in task level dim table with a flag indicator set to 1 for all tasks.
    but while counting the number of cases active with flag indicator 1 (ofcourse when joining case summary table with task dimension table), for a case id only 1 instance of task needs to be accounted (even though it has more than one task , for counting active cases, the flag ind corresponding to a task in a case if set to 1 , then the case is considered active)..but while joining and taking count of case ids with flag indicator as 1, you get the count of every task row of a case which is incorrect logically. how to discard the rest of child records of a case in child table (task dimension table)?
    I am not sure how to achieve this in sql query
    Kindly help!
    Case summary table
    case id, busininess_unit, agent_name
    1001, admin, Ram
    1002, Finance, Sam
    task table
    case id, task_id,task_name, flag_indicator
    1001, 1, 'New', 1
    1001,2, 'Open',1
    1001,3,'In progress',1
    1002, 4, 'New', 1
    (In fact task_id is not a big deal... even you can assume task id doesn't exist..only task name ... )
    now my question... if my query should get the current active cases (ind=1); as per above it should essentially give 2... but my query gives me 4..you know the reason why.. but how do i get the correct count?
    Thanks!

    may be you need just this:
    select count(distinct case_id) from task
    where indicator = 1;
    If this is not what you are looking for, please elaborate and tell us the expected output and rest of the details as mentioned in FAQ Re: 2. How do I ask a question on the forums?:

  • FCE 4, Editing Workshop (Tom's Book) Questions

    Hi Everyone:
    First off, Happy New Year
    I'm new to movie creating, FCE and the lingo. I am trying to make a DVD and thought I better try to walk before I run.
    Based on recommendations here, I purchased Tom's book FCE 4 Editing Workshop. At first it was easy (sorta) but now I'm getting frustrated. Not Tom's fault, just too much info all at once.
    I have searched the forums for answers and have found some, but am stumped so am probably going to ask questions that have been asked before, but here goes.
    1. What is the difference between the Viewer and the Canvas. In the book it says I'll spend a lot of time in the Viewer, I get that but what is the actual reason for two screens.
    2. I'm only up to Lesson 5 (still in it) will the Timeline be explained more?
    3. Is Marking I/O on clips how I remove what I like and leave behind what I don't? Do I use clips to make manageable pieces of viewing tape?
    4. Specific lesson instructions... Page 85 Tom says to Open clip in Viewer, mark specific I/O and then drag that "clip" into a newly created Bin. How the heck do I drag the small 9 seconds of marked I/O to a folder in the browser? I feel like an idiot but I can't get just that small 9 seconds dragged over. I just keep getting the entire clip dragged into a new folder.
    Sorry to be do dense and ask so many questions. I'm technical, but just can't figure this out and it's aggravating.
    I appreciate the help and thank you in advance.
    Regards,
    Kim Cassidy

    G'Day Kim,
    1. What is the difference between the Viewer and the Canvas. In the book it says I'll spend a lot of >time in the Viewer, I get that but what is the actual reason for two screens.
    I'll tackle this one.
    The Viewer is a way to play a clip that is listed in the Browser.
    The Browser does not contain any real media. That sounds crazy, right?
    What is actually in the Browser are file paths to the real clips stored on your Scratch Disc. When you click on a clip in the Browser the file path to the Scratch Disc is established and the real clip plays in the Viewer.
    It's like a short cut to actually going to the Scratch Disc and then playing the file in the QuickTime Player.
    The Canvas and the Timeline are really the same thing displayed in different ways. It's settings are governed by the Easy Setup selected before a Sequence is started.
    Think of the Viewer as a device that plays raw footage and the Canvas a device that plays edited footage.
    Al

  • Address Book Question -- IS THIS POSSIBLE ??

    Is "appending" information possible to address book ? Or like a way to add info from one address book to another with out it deleting anything on the one getting updated OR with out making duplicates of the contact info(s) ????
    Kinda like what we call a "incremintal back up". Like it is able to detect what is NEW info and ONLY save that to it while keeping all the old stuff on it.
    Let me explain --
    I got a tower and a laptop. Address Book (obviously) on both.
    Sometimes the one on my laptop gets some contact info added to it, while the one on my tower does not get that info added to it. OR vise versa.
    I want to combine the two and not lose anything and NOT have to do it manually. Because alot of info has gone down on both recently.
    But at the same time they both have alot of the SAME contacts on them because for a while I was trying to keep up with them and I was manually saving info, then putting it into the other. But recently things have gotten too far and I can not remember which has what, when..
    I NEED to do a incremental save/back up to one of them FROM the other one (combine the both with out causeing duplicates, or with out loseing anything).....
    Please help.
    Thanks -

    Cool, I guess thats good enough... It will get the job done the way I want, so THANKS ALOT Mike !!
    Problem solved.
    I wish in the future though Apple makes it possible to do it how I was saying. Hook your laptop up via firewire to your tower, then Basically a one button click to "append only new info" from the laptops address book. No questions about what to do with duplicates, etc.... just update ALL NEW info. Don't touch old.
    Thanks again though my friend, your reply was extremely valuable to me.

  • 8.9 6.7cm book question

    OK I have compiled a photo book which is the 8.9 6.7 cm size.
    I understand that these books are sold in packs of 3.
    If I want 30 books do I enter 30 or 10 into the quantity box?
    This mat seem like a dumb question but I want to double check before placing such a big order.
    Incidentally I may print 1 (or 3!) to check the size and quality - do I enter 1 or 3 in the quantity box?

    Oops! Just noticed once I updated my account that the box incrementgs in threes!

  • IPhoto photo book question

    My wife created a photo book for our son's PK4 class in IPhoto and selected the hard bound option. Is there an easy way to order book as a wire bound or soft cover book short of recreating the book for each print option. Several of the parents in the class do not want the expensive hard cover version. Thanks in advance for any help

    I had the same question and emailed Apple Support. Below is their response. Good luck! Do you know how to add new photos from IPhoto to the list of photos in after you've already started creating the book?
    Thanks!
    When choosing your book design you'll see the option to choose the book
    type and theme. You can also change the theme or type once you've
    started the book.
    This article explains how to change the theme and ensure that no data
    is lost:
    iPhoto: How do I change the theme or type of my book, card, or
    calendar?
    http://support.apple.com/kb/HT1850

  • Random Address Book Question

    Apologies if I've posted in the wrong forum.  I am not quite sure where this question belongs. 
    My mother still uses the ancient Rolodex (see picture below) for her contact information.  I would like to transfer this information to her computer as an early birthday present.  I am hoping that some software or technique exists that can help me avoid the hours and misery of having to enter the names, addresses and numbers from each card ... there are thousands.
    Ideally (and I mean that in the strongest sense of the word), I am looking for a program or service or other mechanism that would
    take the information from a scan of a card (or cards)*
    convert that information to text
    and then either
              (a) provide me the data to copy and paste onto a new cards in the Address Book application or in Outlook, or my Google Address Book.
              OR
              (b) Magically create the cards for me. (Obviously this would be the preferred method in my idyllic computer world.)
    * The only reason I mention scanning the cards is because it is the only way I know of to get the information from the paper card onto a computer.  If there is another method please feel free to tell me.
    While it does not show, I have attempted to ask this question in the least confusing way possible.  Any leads would be greatly appreciated.  Thank you very much.
    A Rolodex ------------->

    You would need a scanner with OCR (optical character regocnition) software. It scans the text and makes an educated guess as to what the letter is and types that into a doc for you. It works best when you are scanning typed text. If it is handwriting it will be pretty spotty getting the letters right. Either way this will be very labor intensive because you will still need to correct any mistakes you find, and it will only save the step of actually reading the cards yourself and typing them.
    The other thing I can think of is when you said service. You could just hire a temp agency to have someone do it for you, paid by the hour. Or maybe a school job wanted board.
    But no magic to create the cards I know of!

  • SCJP 6 Exam  - Book Question

    Hello.
    I'm thinking of taking the SCJP 6 Exam.
    I looked into taking the SCJP 5 Exam a number of years ago, and purchased the SCJP 5 Study Guide from Kathy Sierra. However, work and life got busy, so I did not pursue it any further.
    Would the book I have be good enough to do the SCJP 6 Exam, or should I bite the bullet and purchase the latest 6 book. Or are there any better books or even free online resources out there....
    Any input appreciated.

    user12167069 wrote:
    I looked into taking the SCJP 5 Exam a number of years ago, and purchased the SCJP 5 Study Guide from Kathy Sierra. However, work and life got busy, so I did not pursue it any further.
    Would the book I have be good enough to do the SCJP 6 Exam, or should I bite the bullet and purchase the latest 6 book.If all that busyness earned you some money, I'd say bite the bullet.
    That said, there don't seem to be too many changes (at least according to [url http://en.wikipedia.org/wiki/Java_version_history#Java_SE_6_.28December_11.2C_2006.29]this page; there may be better ones out there) that would affect the test too much. The synchronization, garbage collection and annotation updates are something you might want to check on (although I don't remember a single question about Annotations when I did the v6 test; several on the other two though).
    Also, the SCJP6 book has been out for a while, so I suspect you could get it fairly cheap on Amazon or even eBay.
    Winston

  • Structured book questions

    I have just begun using structured FrameMaker after working in unstructured FM for years. Even after reading the help, I'm having a hard time understanding some concepts.
    All we want to do is open a ditamap in FrameMaker, save as a book, add a TOC and index, and then save as PDF.
    You can save a ditamap as one of the following book files:
    Book w/FM components - saves each XML file as an FM document.
    Book - maintains the XML file formats.
    If all we're doing is adding a TOC, Index, and then saving as PDF, which format do we need?
    Another question - After I save a ditamap as a book, open all files in the book, and then try to update the files, FrameMaker says the XML application for one file cannot be found. When I opened this particular file before updating the book, I chose the structured application and saved the file. After receiving the error, I went to set the structured application, and it was already set. What gives?
    Could this be any more difficult? That's a rhetorical question . I'm very frustrated.
    I appreciate your help.

    I just watched a video on book creation in structured FM (using FrameMaker 8). The suggested solution works without structuring the generated files. In the EDD, it looked like this for the TOC:
    Element (Container): Contents
    General rule: <ANY>
    Valid as the highest level element.
    The index definition was done the same way. TOC and index were added to the book, then the book was generated / updated. After the initial TOC and index generation, TOC and index had the correct element assignments at the book level, but not the correct formatting. The generated content was then deleted from TOC and index, followed by another update. Starting with the second update, TOC and index had correct formatting.
    HTH
    Susanne

  • IPhone Development Book Questions

    My apologies if this should have been posted elsewhere. My question are:
    1: Is there an iPhone Dev forum on this site?
    2: Will an iPhone book written for the iPhone 3 benefit a person wanting to program for the iPhone 4?
    Thanks!

    http://developer.apple.com/devcenter/ios/index.action

  • Address Book Question (possible move from Exchange Server to Mac Server)

    I currently run an Exchange Server. What I like the most about it is that no matter what I use to access my e-mail account, I have my calendar and contacts. Plus everything that I do from any method of access shows up in a different method of access.
    So the question is, if I go to the Mac Server and run mail services with webmail, can I access my calendar, contacts, inbox, sent items, subfolders, etc. from my Mac laptop, and then also from a foreign machine that I use to access the webmail? If I went into webmail, would I have all my contacts available? My calendar? Could I check my sent items or subfolders?
    Pointers to relevant documentation would be a plus.
    Thanks very much in advance.
    Jeff

    you can piece most/all of it together... but it's certainly not as integrated the way exchange is...
    If your main concern is sharing mail folders among several machines and with webmail, this is easy to handle with imap... you could share sent, inbox, etc.
    Shared Address Books can be setup with LDAP.. it takes some work though and is a far cry from Exchange...
    If you are a tinkerer and your staff can put-up with the tinkering, you could piece many of the features together... but if you are happy with, and use, the exchange features- I'd stick with it.
    Jeff

  • Counting vowels question

    Have the user input a sentence. Count the vowels and output your findings. Vowels are comprised of the letters: a e i o u. Remember that a vowel can be in upper case or lower case. (e.g., A or a)
    Your program could look as follows:
    im very confused..

    What is your question?  It looks almost as if you are submitting school assignments for people to solve for you here.
    If you are looking for an idea of how to code this, one way would be to create an array that contains the vowels and loop thru the sentence (String) and test each character to see if it is in the array (use the Array.indexOf() method).  Keep a count of how many match what is in the array.

  • E book question?

    Hi there , I purchased a book called High Probability Trading back in 2008 ish
    It opened on Adobe editions fine back then on my old laptop which is running on Windows 2000
    I havent used that laptop for a couple of years.
    I started it up today, but I cant open the book on adobe editions, there is an error 2038
    I cant seem to transfer it to my other laptop either which is running on windows XP
    Can anyone offer me a solution please?

    Apparantly 2038 is inability to connect to server.
    See some suggestions at https://getsatisfaction.com/booksonboard/topics/adobe_digital_editions_gives_me_error_2038 _when_i_try_to_download_how_do_i_get_my_book
    for example, temporarily turn off your firewall.
    Someone else says it may be a version conflict.  http://support.diesel-ebooks.com/kb/article/troubleshooting-questions/i-receive-error-2038 -in-adobe-digital-editions
    It could be that the AdobeID registration has got confused; it does sometimes.
    Try clearing it using ctrl-shift-D to ADE, restart ADE, and reapply your old registration.
    Then see if you can open the book.
    If you need to reinstall ADE, v1.7.2 is probably your best bet.  There are lots of issues with 2.0, especially on older machines.
    Version 1.7.2, it is a little difficult to find, available on Adobe site for Windows and for Mac.
    http://helpx.adobe.com/digital-editions/kb/cant-install-digital-editions.html
    The forum software is sometimes corrupting the link above.  There shouldn't be a blank in 'editio ns.html'.  The following redirects to the same page: http://tinyurl.com/diged172

  • HT1725 Audio Book Question

    I downloaded an audio book off of my iphone.  It downloaded part 2 and part 3 of the book but part 1 is missing.  There is nothing in my download to finish downloading, and when I try to redownload from itunes store it says already purchased.  Any sugestions?

    Hello paradiseboy,
    Thanks for the question. You definitely have the correct idea, we'll need to try redownloading this purchase. The iTunes Store has detected that it is already downloaded to your device, hence the "Purchased" button. To re-download, you'll need to delete the audiobook first, then return to the purchased section.
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/HT2519
    Thanks,
    Matt M.

Maybe you are looking for

  • Prevent auto data deletion of records from gl_interface table after success

    Hello All, I currently developing the journal conversion. I have successfully imported some sample journal data. But the problem here is i am not able find the successfully uploaded journal data in the gl_interface table.It is getting deleted after s

  • Opening URL from Form

    Anybody has any idea of how to open an url (or webpage) from a webform in the same window. I cannot use Web.Show_Document() as it opens the webpage in a new window. Thanx in advance.

  • Iterate Ove r Array In Soap RPC response

    Hello, I'm new to JCAPS so forgive me if I'm missing something obvious. I need to interact with a remote web service that has a SOAP binding style of RPC. It returns an array whose items are a complex type. I am trying to call this from a business pr

  • Problem got when setting up Sharepoint 2010

    Hi, As Filter pack 2.0 is one pre-requisite of Sharepoint 2010, but when setting up this Microsoft Filter Pack 2.0 (KB2837594) 64-Bit Edition I get this  As I'm setting up Sharepoint 2010 on the server, BTW, can I use ASP.NET v4.0, instead of v2.0, m

  • Cisco 3750v2 VS 3850

    Hi, We are in the process of replacing an order for Cisco switch and we got an upgrade offer without extra cost from 3750 V2 to 3850, 1- Is there a technical comparison between the two models? 2- Our big concern is about stacking, how many is support