How Can I Fix My Decode and Mod Code In The SQL

I have the following SQL statement.
SELECT BEG_SVC_DT, END_SVC_DT,
DECODE((SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1),30,mod(trunc(months_between((to_date('20'||end_svc_dt,'YYYYMMDD')),BEG_SVC_DT)),12)+ 1,
mod(trunc(months_between((to_date('20'||end_svc_dt,'YYYYMMDD')),BEG_SVC_DT)),12))
FROM SVC_OCCURRENCES
WHERE SUBSTR(END_SVC_DT,1,1) IN '0'
AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
Now if the decode returns a value of '30' then 1 is added to the remainder using
the MOD function otherwise the MOD function is used and 1 is not added which is
alright.
After a '1' is added to the remainder , a value of '1','2','3','4', '5','6','7','8','9','10','11','12' is obtained which is alright also.
However I do not want a '12' to appear instead I want a '0' (zero) to appear. Can I do this in an SQL statement? Eventually I want to do this in a report.

SELECT BEG_SVC_DT, END_SVC_DT ,
DECODE(
(SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,5,2)+1),30,
mod(trunc(months_between(add_months(to_date('20'||end_svc_dt,'YYYYMMDD'),1),to_date('20'||BEG_SVC_DT,'yyyymmdd'))),12),
mod(trunc(months_between((to_date('20'||end_svc_dt,'YYYYMMDD')),to_date('20'||BEG_SVC_DT,'yyyymmdd'))),12))
FROM SVC_OCCURRENCES
WHERE SUBSTR(END_SVC_DT,1,1) IN '0'
AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
Hope this Helps
Stan

Similar Messages

  • HT1688 my iphone 5 is stuck on the recovery mode and everytime i tried to restore it , it said that my phone have error 21, how can i fix it or send my phone to the appstore ?

    my iphone 5 is stuck on the recovery mode and everytime i tried to restore it , it said that my phone have error 21, how can i fix it or send my phone to the appstore ?

    Follow this one as well...
    http://support.apple.com/kb/TS3694

  • When I try to quit firefox, it hangs. I cannot force quit and I cannot restart. I tried the online help which directed me to uninstall, but I couldn't find library /application support. How can I fix this without having to turn off the computer?.

    I cannot force quit and I cannot restart. I tried the online help which directed me to uninstall, but I couldn't find library /application support. How can I fix this without having to turn off the computer?.

    Not sure if this Term is Relevant towards an iPhone but, my iPhone won't Post unless if it's plugged into a Charger.

  • I deleted the font section but everything in Photoshop CS5 works.  How can I fixed this because I use fonts all the time? I don't want to purchase another one since this cost me $699:(

    I purchased PhotoshopCS5 Sept 2010 and still use the same MAC. I invertly deleted the font section but everything else works.  How can I fixed this because I use fonts all the time? I don't want to purchase another one since this cost me $699:(

    Which version of mac os x are you using?
    Could you clarify what you mean by "I invertly deleted the font section"

  • How can I do to acquire and save date in the same time and in the same file when I run continual my VI without interrupti​on.

    I've attached a VI that I am using to acquire amplitude from Spectrum analyzerse. I tried to connect amplitude ouput to the VI Write Characters To File.vi and Write to Spreadsheet File.vi. Unfortunately when I run continual this VI without interruption, labview ask me many time to enter a new file name to save a new value.
    So, How can I do to aquire and save date in the same time and in the same file when I run continual my VI for example during 10 min.
    Thank you in advance.
    Regards,
    Attachments:
    HP8563E_Query_Amplitude.vi ‏37 KB

    Hi,
    Your VI does work perfectly. Unfortunately this not what I want to do. I've made error in my last comment. I am so sorry for this.
    So I explain to you again what I want to do exactly. I want to acquire amplitude along road by my vehicle. I want to use wheel signal coming from vehicle to measure distance along road. Then I acquire 1 amplitude each 60 inches from spectrum analyzer.
    I acquire from PC parallel port a coded wheel signal coming from vehicle (each period of the signal corresponds to 12 Inches). Figure attached shows the numeric signal coming from vehicle, and the corresponding values “120” and “88” that I can read from In Port vi.
    So I want to acquire 1 time amplitude from spectrum analyser each 5
    period of the signal that I am acquiring from parallel port.
    So fist I have to find how can I count the number of period from reading the values “120” and “88” that I am acquiring from In Port (I don’t know the way to count a number of period from reading values “120” and “88”).
    Here is a new algorithm.
    1) i=0 (counter: number of period)
    2) I read value from In Port
    3) If I acquire a period
    i= i+1 (another period)
    4) If i is multiple of 5 (If I read 5 period)
    acquire 1 time amplitude and write to the same
    file this amplitude and the corresponding distance
    Distance = 12*i). Remember each period of signal
    Corresponds to 12 Inches).i has to take these
    values: 5,10,15,20,25,35,40,45,50,55,60............
    5) Back to 2 if not stop.
    Thank you very much for helping me.
    Regards,
    Attachments:
    Acquire_Amplitude_00.vi ‏59 KB
    Figure_Algorithm.doc ‏26 KB

  • How can i fix my disabled ipod on itunes without the password?

    How can I fix my disabled ipod on itunes without the password?

    See Here
    http://support.apple.com/kb/HT1808
    If you cannot remember the passcode, you will need to restore your device on the computer that you Usually Sync with...
    Wrong Pass Code
    http://support.apple.com/kb/HT1212

  • My iPad was stolen, how can I have it blocket and/or send to the iPad a message to get it back

    My iPad was stolen, how can I have it blocket and/or send to the iPad a message to get it back

    If you enabled Find My iPad on it before it was stolen, and if it is still turned on and connected to the internet with Find My iPad enabled, you can do this by going to icloud.com as explained here: http://help.apple.com/icloud/#/mmfc0f0165.

  • How can i use both Windows and Mac os at the same time on my iMac

    How can i use both Windows and Mac os at the same time on my iMac

    You can use Parallels desktop or VM Fusion to run both operating systems at the same time. Both programs work well, but I personally perfer VM Fusion.

  • I had an App on MacBook Air which would cause my computer to be locked. I delted it and reinstalled the App again from the AppStore. Now I am being charged again for the same App. How can I correct this issue and get refund for the double billing?

    I had an App on MacBook Air which would cause my computer to be locked. I delted it and reinstalled the App again from the AppStore. Now I am being charged again for the same App. How can I correct this issue and get refund for the double billing?

    You can't gift it, gifting can only be done from within the store, not from within your library.
    Puchases are considered final but you can try the 'report a problem' link to contact iTunes Support and see if they will refund or credit you : http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes Support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • HT1459 My daughter forgot the password to her IPod & disabled it.  How can I fix this? I do not have the serial number because it was purchased used!

    My daughter reset her IPod and after doing so the Ipod asked for a password.  We do not have a serial number for the Ipod as it was used.  The IPod is now disabled.  How can I fix this?

    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...
    Be sure to Follow ALL the Steps...
    But... if the Device has been Modified... this will Not necessarily work.

  • How can i fix a member for a dimension in the transformation file?

    Hello everybody,
    anyone knows how can I fix a dimension member using the *mapping section of the transformation file in a data upload, I´m trying to fix the member for the Category dimension, I´ve tried an instruction like:
    *MAPPING
    *CATEGORY=ACTUAL
    but it doesnt work, any idea?
    thanks!

    The easiest way is to use the folloowing in the Transformation file:
    Category = *newcol(Actual)
    Hope this jelps.

  • How can I fix Voxer app Speakerphone mode?

    I love the Voxer app as I find it is a more efficient way of communicating. A few months ago, however, and for no apparent reason the Voxer app stopped functioning properly. I normally use it in Speakerphone mode as if it is a walkie-talkie but suddenly the app stopped allowing my voice to be recorded while in speakerphone mode. I can receive audio messages from others while in speakerphone mode and they will play through the speaker but my voice will not record and when the other party receives the message that I have sent it does not have any audio contained in it. The app will still function normally in Headset mode but I do not prefer this mode. I contacted Voxer directly and have been working with them to resolve this issue for the past few months. We literally have tried every possible fix besides replacing my phone. We have, enabled and disabled the mic in the settings, we have deleted and reinsalled the app, we have sent debugging details from each message recorded, we have upgraded the app to the pro version, we have experimented with a beta version that I was allowed to test on my phone, we have also restored my phone from a backup and as a new phone after erasing the entire phone. Nothing has fixed this issue and yet when testing out other apps that use the mic in the same manner that Voxer does while in speakerphone mode all the other apps function as they are supposed to, this includes the stock apple Voice Memo app. Voxer has no other known issues of this type from other users which leads me to believe that somehow my phone's hardware deciced to not allow Voxer to function in Speakerphone mode. Does anyone at Apple or that is a developer know what could have caused this or how it can be fixed? Is this an issue that I could get my phone replaced because of? Thanks for any suggestions as they are very welcome.

    What is the problem you are having?
    iOS: An app you installed unexpectedly quits, stops responding, or won’t open
    Contact the developer/go to their support site if only one app.
    Restore from backup. See:
    iOS: How to back up
    Restore to factory settings/new iPod
    Last, request a refund

  • How can i fix my headphones and my microphone from buzzing?

    So i got a new headset the razer carcharias and when i plug it in to the back of my iMac it makes a buzzing sound. i have a syba usb stereo audio adapter for a mic and headphone jack but the headset requires both mic and headphone adapter and a usb port to work. every time i try to hear or talk it would i have a loud buzzing sound. It won't stop only when i shut down my iMac and if i don't it will just keep buzzing. when i plug the usb thats when it starts making the buzzing. i have tried all the usb ports on my mac but each one were the same. i don't know how to solve this and its very frustrating. btw i plug my iMac in a wire cable not the one on the wall idk if that makes any difference but i read something about the cable. PLZZ HELP!

    SELECT BEG_SVC_DT, END_SVC_DT ,
    DECODE(
    (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,5,2)+1),30,
    mod(trunc(months_between(add_months(to_date('20'||end_svc_dt,'YYYYMMDD'),1),to_date('20'||BEG_SVC_DT,'yyyymmdd'))),12),
    mod(trunc(months_between((to_date('20'||end_svc_dt,'YYYYMMDD')),to_date('20'||BEG_SVC_DT,'yyyymmdd'))),12))
    FROM SVC_OCCURRENCES
    WHERE SUBSTR(END_SVC_DT,1,1) IN '0'
    AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
    Hope this Helps
    Stan

  • How can I fix Firefox 18 and 19 from taking too long to close when custom settings for history is used?

    Hello, please read entire post before answering, thanks!
    I had Firefox(FF) 12.something and was happily using it when I had to get a new hard drive and start over, so I decided to upgrade to the latest FF of the moment, 18.something...
    After going through setting up all the different add-ons etc.. and resetting the options/preferences (not cool how you all reset those every time it updates!) The time to open and close went from 2-4 seconds each to 78 seconds to open and 48 seconds to close. Over the last two days I tried (except reset) and read all the suggestions here to no avail.
    So I read up on how to totally uninstall all traces of Firefox so I could do a clean install, that didn't work either: The freshly reinstalled FF 18.? program still opened and closed in the same times, and had all my info despite my deleting the folders/sub-folders said to hold that info. I turned everything off in FF, still no improvement, so again I tried to find accurate info on how to completely remove FF and still nothing that is correct for the current programs.
    Today I looked again for info on how to totally remove FF, found something new to me, and tried that, including a complete search of the registry and removing everything with the firefox name, then reinstalled FF 18.?
    Again all my bookmarks and info was there, and when I looked up help it auto-updated to 19.0 without my permission, again I don't like others making decisions for me for "my own good"(hence the screen name), not OK!
    So I tried the reset feature in FF 19.0 and it did just that and the opening and closing lag times were gone, back to 2-4 seconds each,which seemed great!,but no.
    When I went back to set up my options and restarted, FF went back to the lag, so I eventually removed/reset everything and all was well again, so I started putting/setting things back one at a time, that's when I found and verified the problem, the history settings!!!
    I repeated this 6 times with the same results:
    Set the History to Remember, and everything works fine, set the History to Custom the lag returns without fail.
    My settings in Custom were:
    Accept and remember everything until I close FF
    Clear history when FF closes.
    In the sub-menu "Settings" under the Clear History when FF closes:
    All 6 boxes are checked for History and no boxes were checked for Data (all the defaults)
    I looked at the processes running in Task manager when starting and stopping FF with these settings,I found that not only was FF.exe running but also a plugin-container.exe, both eventually stop after about 48 seconds, the plugin container does not appear to run when History is set to Remember all... (I have an incomplete memory about the plugin container causing problems like this in the past but I cant remember what or exactly when so...)
    I also tried leaving the History setting to Remember All and the restarted and tried to clear everything through the Tools menu and FF stopped responding for about 60 seconds and then seemed fine afterward.
    So I conclude that there is a problem in the newer versions with clearing History in the background while the browser continues to function, and the likely culprit is the plugin container(again?)...
    So on to the questions...
    Is it possible to set History to Custom and have FF 19.0 remain operational during that process and for FF to close in a few seconds as it did in FF 12.something with the same History settings?
    If so how can I set that up?
    If not, what is the latest version that will work correctly with the History being remembered until FF is closed and then wiped before re-opening, without waiting more than a few seconds for it all to happen as it was in my FF12.? version?
    Also, How do I remove ALL TRACES of Firefox 18.? and up so that I can do a clean install if I need to, as I said everything that is here or linked to from here up to today, 2/21/2013, was not sufficient.
    Thanks for your time...

    So now on to question #2 of the original post...
    "Also, How do I remove ALL TRACES of Firefox 18.? and up so that I can do a clean install if I need to, as I said everything that is here or linked to from here up to today, 2/21/2013, was not sufficient."
    Why?
    As it turns out, the plugin-container.exe rears its ugly head yet again. With as many as four instances trying to run at once, and locking FF completely whenever I try to watch videos online. (Google Chrome has no problems with the same videos on the same sites with the same software available to it on the same drive on the same machine, so it is definitely something in FF)
    Also:
    1. ) The auto update for; plug-ins, FF itself, add-ons, etc..., refuses to stay disabled.
    I've read others saying that as many as five different areas need to be found and addressed in order to fully disable many of the "hidden" functions of the latest Firefox editions, yet I can't find a definite answer nor instructions to fully address this accusation nor can I find complete and full details/ instructions on how to completely uninstall all data connected to Firefox. I have followed what I can find so far and when I reinstall, all my personal data is there including bookmarks etc... so something isn't getting done...
    2.) Whomever is in charge of "security"(Villalobos?) keeps disabling my plugins which is keeping me from using FF to some extent and may or may not be keeping the videos from playing while on-line and who knows what else, but as I have stated before I'm against anyone doing anything for any reason under the Hitler/Stalin-esque ideology that "the ends do justify the means", for example:
    ''Java Plugin 7 update 12 to 15 (click-to-play), Windows has been blocked for your protection." Why was it blocked?
    Old versions of the Java plugin are potentially insecure and unstable. All users are strongly recommended to update on our plugin check page.
    Who is affected? All users who have these versions of the plugin installed in Firefox.
    What does this mean? The problematic add-on or plugin will be automatically disabled and no longer usable.
    When Mozilla becomes aware of add-ons, plugins, or other third-party software that seriously compromises Firefox security, stability, or performance and meets certain criteria, the software may be blocked from general use. For more information, please read this support article.
    Blocked on February 25, 2013. View block request.''
    So as a last resort I'm going to downgrade to something that the socialist people who are now making decisions for the masses that use the newer editions of Firefox can't control (hopefully) and manipulate against my (our) will.
    So I need your help cor-el to be able to remove ALL files/instructions/data in order to downgrade without anything "new" being left behind after uninstalling, presuming you know how to accomplish this and will share it with me and everyone else who wants to continue to use Firefox without someone else deciding what we can and can't do with it.(it is still open-source right?)
    3.) I use my computer and browser for my business, I can't afford spending all this time and trouble trying to undo what Jorge Villalobos( and those who think as he does) continue to do, apparently believing that it's ok to cost me (us) time and money in the name of "protection", he really doesn't get it, and I'm done putting up with socialists (or control freaks pretending to be socialists) trying to run my computer. Take a friggin' Philosophy/Logic class and learn why the ends NEVER justify the means Jorge....
    4.) This is as plain as it gets Jorge et al.: MY Computer, My Choice!...
    5.) So what do you say cor-el, will you help me in this?

  • HT3406 i bought a i-phone 4s from cex i reset the phone to factory setting ow i am stuck on activion lock and no way to contact preveious owner and cex wont take it back as i dont have the receipt anymore how can i fix this or get in contact with the prev

    i wud be gratefull for any help
    like i say i bought it from cex working then as soon as i rset it to factory setting it ask for the person email and password but cant return it as i havent got the recipet anymore

    You can't fix this, called Activation Lock, & currently there is no way around it. With no way to contact the previous owner, & no way to get your money back, you own a useless paperweight.
    Apple can't/won't help you.

Maybe you are looking for