Pivot will not get result in the select statement

This is the version of oracle 11g R2 on windows details 7 OS

CREATE TABLE OTBOOKINGDETAILS
(EMPNO VARCHAR2 (10 BYTE),
DATE OF OTBOOKEDDATE,
NUMBER (5.0) DAY OF THE WEEK.
DAYCEILINGHRS VARCHAR2 (10 BYTE));

Here is the data

INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 MARCH 2013', 1,' 09:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 APRIL 2013', 2' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 MAY 2013', 3,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 JUNE 2013', 4' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 JULY 2013', 5,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 AUGUST 2013', 6,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 SEPTEMBER 2013', 7,' 00:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 MARCH 2013', 1,' 09:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 APRIL 2013', 2' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 MAY 2013', 3,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 JUNE 2013', 4,' 02:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 JULY 2013', 5,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 AUGUST 2013', 6,' 04:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (102 ', 3 SEPTEMBER 2013', 7' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 OCTOBER 2013', 1,' 00:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 NOVEMBER 2013', 2' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 3 DECEMBER 2013', 3,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 13 MARCH 2013', 4,' 04:45 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 14 MARCH 2013', 5,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 15 MARCH 2013', 6,' 01:00 ');
INSERT INTO OTBOOKINGDETAILS VALUES (101 ', 16 MARCH 2013', 7' 01:00 ');

Here, I want to Dayceiling hours below the output using pivot

EMPNO OTBOOKEDDATE DAY1_HRS DAY2_HRS DAY3_HRS DAY4_HRS DAY5_HRS DAY6_HRS DAY7_HRS
101 03/03/2013 09:00 01:00 01:00 01:00 01:00 01:00 00:00
102 03/03/2013 09:00 01:00 01:00 02:00 01:00 04:00 01:00
101 03/10/2013 00:00 01:00 01:00 04:45 01:00 01:00 01:00

ChakravarthyDBA wrote:
I need to include the pivot query in the select statement

Can' are you use PIVOT here since you do not know from the start what values OTBOOKEDDATE. So use:

select  empno,
        otbookeddate - weekday + 1 otbookeddate,
        max(
            case weekday
              when 1 then dayceilinghrs
            end
           ) day1_hrs,
        max(
            case weekday
              when 2 then dayceilinghrs
            end
           ) day2_hrs,
        max(
            case weekday
              when 3 then dayceilinghrs
            end
           ) day3_hrs,
        max(
            case weekday
              when 4 then dayceilinghrs
            end
           ) day4_hrs,
        max(
            case weekday
              when 5 then dayceilinghrs
            end
           ) day5_hrs,
        max(
            case weekday
              when 6 then dayceilinghrs
            end
           ) day6_hrs,
        max(
            case weekday
              when 7 then dayceilinghrs
            end
           ) day7_hrs
  from  otbookingdetails
  group by empno,
           otbookeddate - weekday + 1
  order by otbookeddate,
           empno
/

EMPNO      OTBOOKEDDA DAY1_HRS   DAY2_HRS   DAY3_HRS   DAY4_HRS   DAY5_HRS   DAY6_HRS   DAY7_HRS
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
101        03-03-2013 09:00      01:00      01:00      01:00      01:00      01:00      00:00
102        03-03-2013 09:00      01:00      01:00      02:00      01:00      04:00      01:00
101        10-03-2013 00:00      01:00      01:00      04:45      01:00      01:00      01:00

SQL> 

SY.

Tags: Database

Similar Questions

  • Windows will not honor "always use the selected program to open this type of file."

    When I try to open a file *.img using 'open with... '. "I get a window of"Leader Type Helper"asking what software I want to use.  I have check "open this file using a software program (sic) that (sic) is already installed."  This very unnecessarily opens another dialog box titled 'open with' * Sub * the files already browser window fill the screen while I'm not yet aware that the box is here.  Having managed to find, I choose "7-Zip File Manager" and click on the box always saying "use the selected program to open this type of file", and then click OK.  This opens the file using the selected program, as you wish.

    However next time I try to open a *.img file, I again get the window "Help file of Type" and must go through the whole process again.  (By double-clicking on the file shows "Windows Disc Image Burner".)  Why don't Windows 'always use the selected program' like I asked?  Windows is aware that I have chosen before, because it is considered to be the only 'recommended program' in the 'Open with' dialog box  Thanks for any help!

    Care to try another tool?  This small utility can help: http://izt.name/apps/types/

    You will find the file type in the list of icons (.img files, then), and then to change what he uses to open the file by clicking on the option 'open' and edit the properties.

  • Table (ADF 11 g) does not get updated on the selection of lines...

    Hi all

    I have a table element (ADF 11 g) in my page with the selection of multiple lines. I have my own row selection listener. Whenever I have select several lines with the CTRL key, the table is getting updated. It is fetching the data again for each selection. I don't want the table to get updated whenever I select a line. In the im listener manually selected do the line current. The code below is the table row selection listener.

    public void tableRowSelectionListener (SelectionEvent selectionEvent)
    {
    Add the code in the event here...
    String tableRowSelectionListener = "tableRowSelectionListener";
    Table richeTableau = (RichTable) selectionEvent.getComponent ();
    Set of keys to RowKeySet = table.getSelectedRowKeys ();
    Txn_id = number ((Number) ((Key) ((List) keySet.toArray () [0]) .get (0)) .getAttribute (0));
    int noRowsSelected = ((List) keySet.toArray () [0]) .toArray () .length;
    Rank [txnrows] = null;
    if(noRowsSelected == 1)
    {
    PscTransactionsViewImpl txnVO = (PscTransactionsViewImpl) amImpl.getPscTransactionsView2 ();
    if(txnVO!=null)
    txnrows = txnVO.findByKey (new Key (new Object [] {txn_id}),-1);
    If (txnrows! = null & & txnrows.length > 0)
    {
    SelectedRow PscTransactionsViewRowImpl = (PscTransactionsViewRowImpl) txnrows [0];
    txnVO.setCurrentRow (selectedRow);
    }
    }
    }

    How to select a row in the table easily (without the table is refreshed). ?

    Thanks in advance,
    Swathi

    Hi swati,

    Set property of 'changeeventpolicy' on 'none' & 'useRowHints' to 'default' for the list that you iterate.

    YP.

  • Several results of the Select statement horizontally

    Hello

    DB Version: Oracle 11.1.2.1.0

    OS: OEL5

    I try to print the results of several SELECT horizontally using SQL statements, but not able to reach my goal.

    Multiple SQLs:

    SELECT 'DB Version', version db_version FROM v$instance
    UNION ALL
    select 'Oracle Client', length(addr)*4 || '-bits' word_length from v$process where ROWNUM =1
    UNION ALL
    select 'Database Edition', trim(substr(banner,20,19)) from v$version where rownum<2
    UNION ALL
    SELECT 'Single Instance or RAC', CASE COUNT(1) WHEN 1 THEN 'Single Instance' ELSE 'RAC' END is_single_instance FROM gv$instance
    UNION ALL
    SELECT 'No of CPUS', to_char(value) FROM v$osstat WHERE stat_name='NUM_CPUS'
    UNION ALL
    SELECT 'No of CPU Cores', to_char(value) FROM v$osstat  WHERE stat_name='NUM_CPU_CORES'
    UNION ALL
    SELECT 'No of CPU Sockets', to_char(value) FROM v$osstat  WHERE stat_name='NUM_CPU_SOCKETS'
    UNION ALL
    SELECT 'Physical Memory (GB)', to_char(ROUND((value/1024/1024/1024),3)) FROM v$osstat  WHERE stat_name='PHYSICAL_MEMORY_BYTES'
    /
    
    

    Result:

    'DBVERSION'            DB_VERSION
    ---------------------- ----------------------------------------------------------------------------
    DB Version             11.2.0.1.0
    Oracle Client          64-bits
    Database Edition       Enterprise Edition
    Single Instance or RAC Single Instance
    No of CPUS             4
    No of CPU Cores        2
    No of CPU Sockets      1
    Physical Memory (GB)   3.864
    
    
    8 rows selected.
    
    

    Expected result:

    DB VERSION  ORACLE CLIENT   DATABASE EDITION         SINGLE INSTANCE OR RAC     NO OF CPUS  NO OF CPU CORES  NO OF CPU SOCKETS  PHYSICAL MEMORY (GB)
    ----------- --------------- ------------------------ -------------------------- ----------- ---------------- ------------------ ---------------------
    11.2.0.1.0  64-bits         Enterprise Edition       Single Instance            4           2                1                  3.84
    
    

    Any help would be greatly appreciated.

    Val

    SELECT "DB Version."

    "Oracle Client."

    "Database Edition."

    "Single instance or RAC.

    "None of the processors."

    "No CPU Cores.

    "No CPU Sockets."

    "Physical memory (GB).

    OF (choose the version "DB Version" of v$ instance where rownum)<>

    (choose the length (addr) * 4 | bits "Oracle Client" from v$ process where ROWNUM = 1).

    (select trim (substr (banner, 20: 19)) "Database Edition" version $ v where rownum)<>

    (select CASE COUNT (1) WHEN 1 THEN 'Single Instance' ELSE 'RAC' END 'Single Instance or RAC' SGS $ instance).

    (SELECT to_char (value) 'Number of processors' v$ stat_name WHERE osstat = 'NUM_CPUS'),

    (SELECT to_char (value) "Number of CPU cores" v $ stat_name WHERE osstat = 'NUM_CPU_CORES'),

    (SELECT to_char (value) 'number of CPU Sockets"v$ stat_name WHERE osstat = 'NUM_CPU_SOCKETS'),

    (SELECT to_char (ROUND ((value/1024/1024/1024), 3)) 'physical memory (GB)' v $ stat_name WHERE osstat = "PHYSICAL_MEMORY_BYTES")

    /

    DB Version Oracle customer Database Edition Single Instance No. No. processors CPU Cores No. CPU Sockets physical memory (GB)
    ----------------- --------------- ------------------- --------------- ---------- --------------- ----------------- --------------------
    11.2.0.3.0 64-bit Enterprise Edition Single Instance 4 4 and 1 7.991

    SQL >

    SY.

  • Version 31 will not get messages from the imap without security the value none Server

    I've updated Thunderbird version 24 to 31. My mail server is an imap server and has always worked well. Since I've upgraded to version 31 I can't recover my mail unless the connection security is set to zero and the port is 143. The imap server using SSL/TLS with port 993. It worked for me on the old version of 24, but now it won't.

    Suggestions? I cannot continue to use no security connection, but would not be pretty.

    you have mail scanning in your anti virus? SSL trips them something terrible and can cause this your light.

  • How can I add a footer to the main section that will not get push off-page?

    Generator 10.1.2.2.0
    ORACLE Server Release 10.1.0.5.0
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production

    Hi all

    I want to add a footer frame in the main section of a report that will not get pushed off the page by an extensible framework above it, which can develop vertically, but will still allow the extensible framework continue on the next page (and print another foot on this page as well. I paint a blank on how to do it with anchor or frameworks encompassing etc points.

    Extend the extensible framework until the footer frame. Change the elasticity vertical expandable framework to contract or fixed. In this case, pull-out frame will be printed until the foot of the page and will then continue on the next page.

    I hope this helps.

  • Error code 204 trying to download CC on new laptop (2nd computer) it will not download and receive the error code 204. I tried turn off anti-virus and firewall and get the same error code. How do we install CC?

    Error code 204 trying to download CC on new laptop (2nd computer) it will not download and receive the error code 204. I tried turn off anti-virus and firewall and get the same error code. How do we install CC?

    Please ignore. I disabled the anti-malware and the app is trying to install.

    Thank you

  • I went to Adobe Creative cloud to install Bridge. I pressed the button download next to the bridge and my creative cloud now says "update installation...". "but the sequence is at 0% and will not get above. Please help me, thanks

    I went to Adobe Creative cloud to install Bridge. I pressed the button download next to the bridge and my creative cloud now says "update installation...". "but the sequence is at 0% and will not get above. Please help me thank you all

    Hello

    Please quit Setup and then exit the creative application of cloud.

    After that, restart the machine.

    Let us know if that helps.

    Kind regards

    Bani

  • HP Envy 7640: HP Envy 7640 will not print photos from the photo tray

    I bought a HP Envy 7640 today, 11/05/2016.  It will NOT print photos from the photo tray.   The printer has paper in all trays, but keep taking 8 1/2 x 11 paper rather than photo paper.  I use the default application for the display of pictures (Microsoft Office 2010) and have tried selecting both the 4x6in of the index card. and sizes of 4 x 6/10 x 15 cm.  The end result is the same, an image printed in the middle of the plain paper.  I searched the forums and found that two related threads.  Given that I just install the printer today, I figure there will be newer drivers in the last hour, so I finished downloading "printing HP and Scan doctor."  He finds a "Match of Port issue" and that fixed it, but when I printed another picture, he was still on plain paper.  If I remove the paper and leave only in photo paper, the printer throws a fit and said that it is out of paper.  Any ideas?  I'm not a newbie, but in more than 20 years of use of HP products, this is the first time that I had to fill out a problem for a Board of Directors.  (And with the instant the ink program, it starts to accumulate the number of my printing without a single success.)

    RESOLVED - photo, once you select the printer & paper, you must go into OPTIONS, then the properties of the printer, then go to the paper/quality tab, then the paper Source and select manually the specific bac (bac/Photo main tray).  Sheesh, should we not automatic as soon as you select the paper size?

  • Vista will not start. Verifying the integrity of system files and repair has no ErrorCode = 0 x 2 HELP PLEASE!

    ASUS PC, Windows Vist Home premium, all updates.

    Out of the blue, it will not start.  Access the start scrolling (the one just before logon) screen and it just stops.

    Twice I ran Vista check utility.  The first time, I chose to do the system restore to previous state.  Restarted.  Always off.  The second time, it took much longer and from what I can see.  All TESTS PASS, except one:

    Repair action: repair and checking of the filesystem Integrety

    Result: failed. Error code = 0 x 2

    Time required: 6206818ms

    I get no blue screen, I can't even any screen!

    I'm triying to repar because I have several costly software titles that link the authorization key code to a key hardware and software installation.  I don't know that I could reinstall if I get a code (randomly?) different generated software.

    I don't know about i-tunes and other content downloaded my wife has such as MP3 files and audio books.

    Thanks for any help!

    The test fails (SFC) checks for corruption in the files on your system.  If she can't even complete, she suggests the Vista all system needs to be re-installed - but you have already done this and you still have the problem.

    In fact, look like a hardware problem.  Here are some troubleshooting guidelines hardware that can help (but probably not for this question as what you really need, it is a replacement for test):http://elephantboycomputers.com/page2.html#Hardware_Tshoot.  Frankly, I think it's time to take the system to a repair facility of good reputation for the service computer (or to return to the manufacturer for repair - costs, schedule, guarantees and make a decision).  I don't know what hardware component.

    If you can, try to back up your data before you import it it because they will probably wipe the drive clean during the process. You can use Knoppix http://www.knopper.net/knoppix/index-en.html with a good ISO as Copier: http://isorecorder.alexfeinman.com/isorecorder.htm as well as a blank CD (perhaps done on another computer).  This should give you enough access to the system (if you do not have any other means) to backup your important data.  Otherwise, try slaving the drive to another system and access the data in this way.

    I hope this helps.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Create a model that can be replicated, but will not show changes in the original model, which occurs in any comps duplicated from it?

    I imported a doc I - 4 layers. Then I dragged these 4 layers in a new comp - comp1. I would like to reproduce this model so that I can try different things using these same 4 layers. But when I duplicate the comp I did - comp 2 - any change I make appear in comp1. How can I create a model that can be duplicated - but will not show changes in the original model, which occurs in any comps duplicated from it? Thank you very much!

    (CS5.5)

    It is a common misunderstanding when you start working in Ae. It takes time to get used to, and even veterans are still this error from time to time. Here's the thing, you have to get in your head: your project Panel is where your source material is, and the timeline is the place where there is a representation of this source. This means that if you duplicate an item in your timeline (particularly relevant for the precomps) it will duplicate a copy, not the source. so, if change you it - it will change all instances of this copy. If you want to duplicate a precomp and create another source, you will need to do it in a 4 step operation:

    1. duplicate your precomp in the timeline (you got that day)
    2. Select the source of this copy in the project Panel (currently the same precomp)-right click on the-> precomp 'reveal the source layer project.
    3. duplicate the precomp selected in the project Panel
    4. replace the copy in your panel mounting with the duplicate of the Source Panel (shortcut - Ctrl + alt + / when both are selected, or drag it to double with pressing Alt)

    what you are really duplicate the precomp twice - once in the project window and once in the timeline, and then one link to the other.

  • try to change the text in a saved file, but it will not allow isolate me the text, place the cursor in the text box or simply go back to remove.

    try to change the text in a saved file, but it will not allow isolate me the text, place the cursor in the text box or simply go back to remove.

    Hello

    in what format save you your file? If it's a jpg file, then the text is compressed and unfortunately PS is telling things as they are. Even if you could change the text before you save, after having been saved in jpg format, the text is merged and is no longer editable.

    A good solution is to save the files as PSD files, photoshop files. In this case, all layers are saved uncompressed and so your text will appear in its own layer in photoshop. All you need to do in this case to change it is the result of a three-step procedure

    (1) select the right layer

    (2) take the text tool in the tools bar

    (3) mark and change your text

    So the crucial question is: in what format you save your file?

  • The task manager has started to appear without borders and will not go away, unless the computer is off.

    When using the Ctrl-alt-delete option and the Manager tasks appears it seems without borders.  The task manager remains after the programs are all closed and will not go away, unless the computer is off.

    It's called mode 'small footprint '.  Double-click anywhere on the border of the Task Manager window and you will get the Menu bar in the rear.

  • Vista will not display description of the file on mouse over. File name, Type, size, and Date modified see the upward, but no description.

    Vista will not display description of the file on mouse over. When I mouse over, a pop-up window displays showing: file name, Type, size and Date of change, however, it does not show the description of the file.

    So, for example if I have 5 files on different types of screw - the description tells me that the size of the screws. IE. 1.5 mm or 1. 8 mm.

    Update: try to get the description of the file displayed messing around in the file properties, now out of 10 records, only 2 includes the name of the file in the mice on the pop-up window. So now what lack us, it's the file name and the Description file.
    Help, please...

    Description of the file in as long as this is not one of the available variables, which can be shown with ToolTips - but there are others who could easily serve the same purpose. Here are the options:

    Consulted
    Attributes
    Created
    DocAuthor
    DocComments
    DocSubject
    DocTitle
    Modified
    Name
    Size
    Type
    To write

    Here is an article on how to change what is shown. http://www.ghacks.net/2008/02/10/customize-windows-explorer-tooltips/ . It is to change the registry, make sure you so first back it up before doing anything so that you can recover in case you make a mistake (or do the right thing, but it does not work as expected). http://www.instant-registry-fixes.org/how-to-backup-windows-vista-registry/ .

    I hope this helps.

    Good luck! Lorien - MCSA/MCSE/network + / A +.

  • Windows 7 sees my second monitor as "generic non - PnP" and will not let me set the correct resolution

    Hello

    I just installed Windows 7 Professional 64 bit on a new hard drive on my Dell Studio 540. The PC has a graphics card ATI Radeon HD 3450 and has a Samsung 226bw 22 "monitor on the digital output. This works very well, and has the resolution of 1650 x 4050. When I am running Vista (on the previous hard drive), I got a monitor flat 14 "old on the other out, and it worked fine (although at a lower resolution).

    I added a monitor AOC F22s + on the other output, expecting to be able to put this to the recommended 1920 x 1080 resolution. Unfortunately, Windows has developed the driver for this monitor "Generic non - PnP" and will not let me set the correct resolution. To the maximum it will allow is 1600 x 1200, (as well as all other resolutions it allows) do not use the monitor at maximum capacity, which is the ratio of evil anyway, so the display seems tense.

    I run Windows Update, so have the latest drivers. I tried to install the other drivers, but nothing helped.

    I tried to unplug the Samsung monitor and restart the PC, so that the AOC, one was the only monitor it and he always had as 'Generic non - PnP' with the wrong resolution.

    Someone at - it ideas? I'm at my wits end. AOC support did not understand and could only suggest that the monitor was faulty, but the place where I bought it insist that it works very well and so no Exchange or get a refund (no restocking fee, which is a RIP-OFF).

    I really want to use both screens and would appreciate greatly any help that anyone can give. I hope I gave enough information. If I didn't, please let me know.

    Thanks in advance,

    Alan

    PROBLEM SOLVED!

    It turned out that my VGA cable was wrong and that it was not send the right signal to the computer. The screen worked fine with a VGA monitor, but the PC has not said that the new monitor is a PnP I tried a different cable and it worked fine.

    Thanks again to all who have suggested things.

Maybe you are looking for