Stuck with trying to get a decode to match data

I have this little bit of SQL:
WITH sampledata AS
     (SELECT '000000000000000000000000000000000010101' schd FROM DUAL
     union all
      SELECT '000000000000000000000000000000001111111' sch from DUAL
      union all
      SELECT '101000000000100000000000000000000000000' sch from DUAL
      union all
      SELECT '000000000000000000000000000000010000000' sch from DUAL)
SELECT schd
    , sign(to_number(substr(schd, 33))) c0
    , substr(schd, 33) c01
    , substr(schd, 3, 1) c02
    , decode(sign(to_number(substr(schd, 33))),
                     '1', 'Days of week: ' ||
                     decode(substr(schd, 33, 1), '1', 'Su ') ||
                     decode(substr(schd, 34, 1), '1', 'Mo ') ||
                     decode(substr(schd, 35, 1), '1', 'Tu ') ||
                     decode(substr(schd, 36, 1), '1', 'We ') ||
                     decode(substr(schd, 37, 1), '1', 'Th ') ||
                     decode(substr(schd, 38, 1), '1', 'Fr ') ||
                     decode(substr(schd, 39, 1), '1', 'Sa ')) c1
    , decode(substr(schd, 32, 1), 
                 '1', 'Last day of month ',
                 '0', decode(sign(to_number(substr(schd, 33))),
                         '1','Days of week: ' ||
                             decode(substr(schd, 33, 1), '1', 'Su ') ||
                             decode(substr(schd, 34, 1), '1', 'Mo ') ||
                             decode(substr(schd, 35, 1), '1', 'Tu ') ||
                             decode(substr(schd, 36, 1), '1', 'We ') ||
                             decode(substr(schd, 37, 1), '1', 'Th ') ||
                             decode(substr(schd, 38, 1), '1', 'Fr ') ||
                             decode(substr(schd, 39, 1), '1', 'Sa '),
                         '0','Set Days of Month: ' ||
                             decode(substr(schd, 1, 1), '1', '1st ') ||
                             decode(substr(schd, 2, 1), '2', '2nd ') ||
                             decode(substr(schd, 3, 1), '3', '3rd ') ||
                             decode(substr(schd, 4, 4), '4', '4th ') ||
                             decode(substr(schd, 5, 5), '5', '5th ') ||
                             decode(substr(schd, 6, 1), '6', '6th ') ||
                             decode(substr(schd, 7, 1), '7', '7th ') ||
                             decode(substr(schd, 8, 1), '8', '8th ') ||
                             decode(substr(schd, 9, 1), '9', '9th ') ||
                             decode(substr(schd, 10, 1), '10', '10th ') ||
                             decode(substr(schd, 11, 1), '11', '11th ') ||
                             decode(substr(schd, 12, 1), '12', '12th ') ||
                             decode(substr(schd, 13, 1), '13', '13th ') ||
                             decode(substr(schd, 14, 1), '14', '14th ') ||
                             decode(substr(schd, 15, 1), '15', '15th ') ||
                             decode(substr(schd, 16, 1), '16', '16th ') ||
                             decode(substr(schd, 17, 1), '17', '17th ') ||
                             decode(substr(schd, 18, 1), '18', '18th ') ||
                             decode(substr(schd, 19, 1), '19', '19th ') ||
                             decode(substr(schd, 20, 1), '20', '20th ') ||
                             decode(substr(schd, 21, 1), '21', '21st ') ||
                             decode(substr(schd, 22, 1), '22', '22nd ') ||
                             decode(substr(schd, 23, 1), '23', '23rd' ) ||
                             decode(substr(schd, 24, 1), '24', '24th ') ||
                             decode(substr(schd, 25, 1), '25', '25th ') ||
                             decode(substr(schd, 26, 1), '26', '26th ') ||
                             decode(substr(schd, 27, 1), '27', '27th ') ||
                             decode(substr(schd, 28, 1), '28', '28th ') ||
                             decode(substr(schd, 29, 1), '29', '29th ') ||
                             decode(substr(schd, 30, 1), '30', '30th ') ||
                             decode(substr(schd, 31, 1), '31', '31st ')
                      )
                ) schedule                        
  FROM sampledata;
The idea is that the "ECS" contains information of planning, where 31 1 numbers represent the days of the month.

The 3rd line of the sample data contains a schedule reports to run on the 1st, 3rd and 13th of the month.

The SQL returns a match for the 1st of the month, but it does not pick up the calendar for the 3rd or the 13th of the month.

I thought that since the SQL for the 'calendar' column, that he would return to the 3rd, but it's not to do it, even if the "C02" pass, I can confirm that the value for the 3rd the long is a character, I thought I would be be recognized / corresponding to this line:
decode(substr(schd, 3, 1), '3', '3rd ') ||
All advice very much appreciated, thanks!

PS - I know the code is probably very awkward with my big long list of decodes to the days of the month, but I'm not smart enough for a smoother road!

Maybe
decode (substr (ECS, 3, 1), '1', '3').
Instead of
decode (substr (ECS, 3, 1), '3', '3').

Concerning

Etbin

Tags: Database

Similar Questions

  • Stuck with trying to get the max of the table version number

    We have a custom table that contains information on the work packages installed.

    Whenever a package is updated, a new entry is added to the table, with an incremented version number.

    Some examples of data:
    GET sampledata
    WITH sampledata AS
         (SELECT 'TEST0003' NAME
               , '1.1' VERSION
               , 'Installed Work Packet TEST 111' description
               , '18-Jul-2003' install_date
            FROM DUAL
          UNION ALL
          SELECT 'TEST0003'
               , '1.2'
               , 'Installed Work Packet TEST 111'
               , '18-Aug-2003'
            FROM DUAL
          UNION ALL
          SELECT 'TEST0003'
               , '1.3'
               , 'Installed Work Packet TEST 111'
               , '18-Sep-2003'
            FROM DUAL
          UNION ALL
          SELECT 'THIS2003'
               , '2.1'
               , 'Something Else'
               , '01-Jul-2009'
            FROM DUAL
          UNION ALL
          SELECT 'THIS2003'
               , '2.2'
               , 'Something Else'
               , '10-Aug-2009'
            FROM DUAL
          UNION ALL
          SELECT 'THIS2003'
               , '2.3'
               , 'Something Else'
               , '15-Nov-2009'
            FROM DUAL)
    SELECT *
      FROM sampledata;
    I would like to know how to return only the most recent version of each package of the table, but I can't get out.

    For example, the sample data above, I would like to only include:
    NAME               VERSION                DESCRIPTION                            INSTALL_DATE
    ---------------------------------------------------------------------------------------------------
    TEST0003           1.3                    Installed Work Packet TEST 111         18-Sep-2003
    THIS2003           2.3                    Something Else                         15-Nov-2009
    I see she has to somehow select MAX (version) for each different "NAME", but can't get my head around the syntax. What I have to GROUP BY "NAME" and then select the MAX (VERSION) of that?

    Any advice much appreciated.

    Thank you

    Thanks for the sample date!
    Yet another version:

    SQL>WITH sampledata AS
      2       (
      3          SELECT 'TEST0003' NAME, '1.1' VERSION, 'Installed Work Packet TEST 111' description,
      4                 '18-Jul-2003' install_date
      5            FROM DUAL
      6          UNION ALL
      7          SELECT 'TEST0003', '1.2', 'Installed Work Packet TEST 111', '18-Aug-2003'
      8            FROM DUAL
      9          UNION ALL
     10          SELECT 'TEST0003', '1.3', 'Installed Work Packet TEST 111', '18-Sep-2003'
     11            FROM DUAL
     12          UNION ALL
     13          SELECT 'THIS2003', '2.1', 'Something Else', '01-Jul-2009'
     14            FROM DUAL
     15          UNION ALL
     16          SELECT 'THIS2003', '2.2', 'Something Else', '10-Aug-2009'
     17            FROM DUAL
     18          UNION ALL
     19          SELECT 'THIS2003', '2.3', 'Something Else', '15-Nov-2009'
     20            FROM DUAL)
     21  SELECT   NAME, MAX(VERSION), MAX(description)KEEP (DENSE_RANK FIRST ORDER BY VERSION) AS description,
     22           MAX(install_date)KEEP (DENSE_RANK FIRST ORDER BY VERSION) AS install_date
     23      FROM sampledata
     24  GROUP BY NAME;
    
    NAME     MAX DESCRIPTION                    INSTALL_DAT
    -------- --- ------------------------------ -----------
    TEST0003 1.3 Installed Work Packet TEST 111 18-Jul-2003
    THIS2003 2.3 Something Else                 01-Jul-2009
    

    URS

  • Photo on the desk; Problems with trying to get a photo that I sent to my hotmail to my phone account to save on my desktop Windows 8

    I'm trying to get a photo that I sent to my hotmail to my phone account to save on my desktop Windows 8. It just keeps record on a disc or a photo app somewhere in the depths of my computer and won't let me even copy / paste it on the desktop. I need to go to the appropriate desktop - not the tablet screen daft that windows wants that I use which is totally unsuitable for my needs and is quite undesirable.

    I don't know that it is possible that I used to be able to do. I had already downloaded some third party software to make my laptop works properly (for example, the start menu that produces a start menu and does not take me to tablet screen) but I would rather not download it again if I can help it in case this is what caused my laptop to break.

    I don't know that we should not be this difficult! Any ideas?

    Hello

    It depends on little is it a real room attached or part of enamel...

    You should be able to right-click on it and select "save under"... them select the desired location, he saved...

    If it is always to give you a hard time, a miracle can be to save it to your OneDrive and then copy it to your desktop... Or in your user folder.

    You try to use the image for your desktop wallpaper?

  • 6 Lightroom doesn't open, no error message, stuck with trying to open

    Someone at - it help him?  I tried to restart my PC and close but Lightroom 6 does not open correctly, it seems not blocked, no error message.  The night before I stopped back upward at the beginning when the program is closed I didn't made any changes.  I tried to find the lrcat.lock file that is proposed by someone else but can't find it with search for Solution Explorer.

    Katrina

    I tried to install the latest update of lightroom and was some or the problem has been resolved.

    Thanks for your help.

    Katrina

    Sent from my iPad

  • Dynamic action - Get the difference between two dates + times

    I have problems a little dynamic to work action. I'm trying to get the time between two dates with the time difference.

    Here is what I got (this is apex 4.0):

    Two date pickers + two numbers fields (date/start/end times)

    I created a dynamic action on the page who fires on the point lose focus (above points).

    The real action for the DA is the body of the PL/SQL function:
    declare
      end_date DATE;
      start_date DATE;
    Begin
      start_date := to_char(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MON-YYYY HH:MIAM');
      end_date := to_char(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MON-YYYY HH:MIAM');
      :P1_HOURS := end_date-start_date;
    End;
    When I change the values on the page, I get the following error:

    AJAX call back Server error ORA-06502: PL/SQL: digital or value error: character number conversion error to set the value.

    I'm guessing that there is a problem with the date formatting, but I can't make it work. Thanks in advance!

    Hi djston,

    because you chose the dynamic action of 'Set value' with the "Body of the PL/SQL function" type you need to return the value. Try the following code

    declare
      end_date DATE;
      start_date DATE;
    Begin
      start_date := to_date(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MM-YYYY HH:MIAM');
      end_date := to_date(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MM-YYYY HH:MIAM');
      RETURN (end_date-start_date)*24;
    End;
    

    and P1_REQUESTED_HOURS like 'item affected. "

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

    Published by: Patrick Wolf on January 17, 2011 10:54

  • I'm stuck with several GB of music files on my phone and I can't get down them!

    The other day I tried to install an application on my phone, but I didn't have enough memory.  My phone is full of music via iTunes synchronisation dock. So I connected it to my computer to try to make some more room. But there is a problem.

    (1) Apple does not play nice with Palm. Synchronization is no longer permissible or possible. I can't use iTunes to manage/delete music.

    (2) in USB Mode, there is no way to access/view the library. It's just not there.

    I tried Palm support, and they confirmed that the USB Mode is not working. I guess that the library is located in a hidden folder or directory. They suggested that I downgrade my iTunes. Goal that is unacceptable to me because one) it forces me to break the license Apple, b) it is not taken in charge, and c) if there is still a remote chance it will mess up my iTunes library, I won't.

    I'm ready to get off at Palm headquarters and throw my phone to their building.

    Can someone tell me how to delete my library without hacking iTunes?

    I thought about it. Support, put this in your KB. Everyone who was sync via iTunes on a Mac is currently STUCK with several GB of music on their phone that they cannot manage or remove, which makes the Palm Pre a lot less useful than announced.

    USB mode is a waste of time for people on a Mac. These hidden files are never going to be visible, and the library cannot be removed. The solution: go through a PC. Anywhere, any PC will do. Connect your phone to the PC, go to the USB drive Mode and show hidden files, then delete them from there.

    I got an old laptop lying around at the bottom, and the problem was solved lickety split.

  • How to reset AirPort Extreme 10.11.6 OS? How to work with this pinhole? I'm trying to get rid of this flashing yellow light, which began after I installed a new modem from Comcast.

    How to reset AirPort Extreme 10.11.6 OS? How to work with this pinhole? I'm trying to get rid of this flashing yellow light, which began after I installed a new modem from Comcast.

    How to work with this pinhole?

    Usually a paperclip or toothpick or ball pen.

    Stick it in the hole and reset for about 10 seconds until the front led flashes quickly.

    How to reset AirPort Extreme 10.11.6 OS?

    The software method... Unlike the above material method... is to open airport utility and select restore default settings.

    Both methods take you to the same place.

    You can also read the manual...

    Reset to a base station AirPort FAQ - Apple Support

  • I have iphone 4s, icloud locked trying to get in touch with the owner to give it back or unlock it he won't talk, it's gsx is useful in this case? owner is not interested in the phone!

    I have iphone 4s, icloud locked trying to get in touch with the owner to give it back or unlock it he won't talk, it's gsx is useful in this case? owner is not interested in the phone! and he has been blocked me on whatsapp about 6 times when I tried to get in touch with 6 different number what can I do I login apple, name and telephone number of the owners, in the name of the country

    anyone here to help me? am ready to give her phone or money for if it unlock the phone

    * someone sell me the phone on class based internet site

    Thank you

    It's between you and him, Apple won't help you. So if he wants too that the phone doesn't help you, I advise you to stop bothering him, it's a little cheesy, don't you think?

  • I've been trying to get out of my printer and scanner works with the features, it can handle but you need the orginal software cd you can down line load a copy _ @ _. ___

    How can I get a copy of the cd that will work with your old software. I've been trying to get out of my printer and scanner works with the features, it can handle but you need the orginal software cd you can down line load a copy to * address email is removed from the privacy *

    Hi Oscar,.

    Thanks for the post.

    It seems you are trying to download the application printer and scanner. Please answer the following questions, which will help us to guide you in the right direction.

    1. What is the brand and model of the printer?

    Suggestions for a question on the help forums

    http://support.Microsoft.com/kb/555375

    Send us more information to help you better, we will be happy to help you!

  • I'm trying to get my computer to communicate with the printer so it iis 'tail' documents.

    I'm trying to get my computer to communicate with the printer - for the moment that it is 'Queue' documents.

    What should I do to get the printer to work?

    Hello

    1. What is the brand and model of your printer?
    2. how you have connected the printer?

    Download and run the tool Fixit of the article mentioned below and check if this solves the problem.

    Problems printing and printing errors:
    http://support.Microsoft.com/GP/printing_problems

    Kind regards
    Afzal Taher - Microsoft technical support.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • I'm trying to get a file associated with working for TURL:TN3270 in a windows system 7.

    Original title:

    File associations

    I'm trying to get a file associated with working for TURL:TN3270 in a windows system 7. I went to the control panel and clicked on all Associations. I have a list but URL: TN3270 does not appear in this list, so I can put it in a program. What Miss me?

    THIS

    The seller has to walk you, and who ever you are going to send directions, through it.  AFAIK for a protocol to be included in the default programs, it must have been executed.  Maybe if you launched the exe, it could list, but I'm just guessing

  • Trying to get the Brazilian keyboard work with Windows 7

    I just got a new computer with Windows 7, and I'm trying to get a Brazilian keyboard to work with her.  My old computer has XP, and this same keyboard worked fine.  I created another one for when I was using this keyboard, and he'd let me use all the keys (I don't remember what was the keyboard layout I used).

    When I try and configure it with Windows 7, however, there is no keyboard layout that corresponds to my layout.  ABNT and ABNT2 options are similar, and both are missing two key.  My keyboard has the-to the left of the z and the / right of;  Is there an error with the way Windows 7 has implemented one of these keyboards?  Thank you.

    I just bought a windows 7, but before the case was made I said guys from dell, I needed a computer with Brazilian keyboard. also i paid 50.00 dollars more and they have installed the software to change the language of the computer to the Portuguese. Here's the deal, professional window 7 or windows Ultimate edition, you will have the layout and language... to make it work perfectly. Now if you want to get the layout of the keyboard and language on the regular windows 7 all you have to do is go to microsoft.com and download it. hope it will be useful. you will need to find a way to use the keyboard, codes may be an exercise. but in a day or two, you'll discover. Remember to make all updates as soon as you buy a computer. After you set your PC and all new updates start popping up, just download each important updates. all this information was passed to buy me no one selling Dell.

  • I am currently using Lightroom 4. I bought the IMac with the largest memory, but he has quickly filled. To conserve space on my computer, I bought a hard drive and I tried to get my lightroom back up there. (I don't know if I did it correctly or not

    I am currently using Lightroom 4. I bought the IMac with the largest memory, but he has quickly filled. To conserve space on my computer, I bought a hard drive and I tried to get my lightroom back up there. (I don't know if I did it correctly or not) Now, all my photos in Lightroom are "offline or missing", and I have no idea what to do next. Any help would be greatly appreciated.

    I guess you mean not memory and disk space, you want to clear space on the internal drive. Is this correct?

    If you have moved your photos somehow (this is not a backup), please follow these instructions to reconnect photos in Lightroom. Adobe Lightroom - find folders and files moved or missing

    In addition, you must (it is obligatory) make real backups of your database catalog and photos, that means accurate identical copies, made by a method automated and placed on a different physical disk than the originals. Lightroom allows you to make backups of your files of catalog on a regular basis, it is an option under the catalog settings. To make backups of your photos, you need some third party software to do.

  • Trying to get attached with NIKON D 7000 on iMac with El Capitan.  Worked well last time I tried (pre El Capitan).  It is impossible to find the camera but it recognizes for the download of images.

    Trying to get attached with NIKON D 7000 on iMac and Macbook Pro, both with El Capitan.  Worked fine before as the normal shooting form in my studio (pre El Capitan).  It is impossible to find the camera but it recognizes for the download of images.

    Hi jubei.

    Attach cameras Nikon and Leica using Lightroom CC 2015 and Lightroom (also noticed on other versions of Lightroom) 6 is not currently supported on El Capitan. Please see Lightroom and El Capitan | Mac OS 10.11.

    Kind regards

    Assani

  • I bought Acrobat Standard a year and half ago and lost my disc to install it on my new computer. I lost two hours on the phone trying to get a link to download this product. I have my box with my serial number and all I need is a link to

    I bought Acrobat Standard a year and half ago and lost my disc to install it on my new computer. I lost two hours on the phone trying to get a link to download this product. I have my box with my serial number and all I need is a link to download this product. Can someone help me please?

    Hello

    My apologies for the inconvenience, please use the link below to download Acrobat Standard.

    Download Adobe Acrobat products. Standard, Pro | DC, XI, X

    See also, system requirements | Adobe Acrobat Pro DC, Adobe Acrobat Standard DC

    Kind regards

    Bani

Maybe you are looking for

  • Phone, e-mail, message apps gel ios10

    Is there a place for feedback for iOS 10 somewhere and others have this problem? I have reset my phone closed apps and rebooted, but regularly my phone freezes when replying to messages and emails, or when you try to make a call.  It's very frustrati

  • Installed Apps not updated in the App Store

    Updating macOS version 10.12 on MacBook Pro retina Sierra updates (end 2013) available in the App Store. When you try to update, receive the message "Apple Media Services terms and Conditions have changed. " ... To continue, you must read and agree t

  • Time Machine to back up

    What is the necessary step to set up the backup time machine your data on your external drive?

  • Save Active Boolean events and exhibit in a list

    Hello, I'm doing my professional service in a power station combined cycle, I am currently working on a system of monitoring and control of some wells that provide water in the reservoirs for the steam cycle. Most of the program is done, but I work s

  • One of my ID Windows Live ID does not work

    One of my ID Windows Live ID does not work, I can't reset the password (I get an error), I can not connect with her online (I get an error). When I get the Live ID to submit a case on the support of Live ID site I get an error.  To clarify, errors ar