How to generate a value of 0 if the table does not value contain?

Hello

I have a nice select gives me these results:
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:01 36.6 01/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:02 63.4 02/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:03 73.2 03/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:04 78.6 04/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:05 98.8 05/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:06 2008-06-30.4
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:07 23.8 07/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:08 70.8 08/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:09 14 2008-09
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:10 60.4 10/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:11 46 11/2008

You see, the month 12 is missing, because no data exists in the table. OK, that's normal.

But I want to display the result 0 even if nothing in the table for the month 12. The result would be:
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:01 36.6 01/2008
etc...
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:11 46 11/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:12 0 2008-11

I know that I have to generate a list of values for each month and join them.
select add_months(to_date('01'||:P2_DATE_DEBUT, 'mm/yyyy'), level-1) dt from dual connect by level <= 12
Could you please help me this?

It's nice select I already have.
SELECT 'f?p=&APP_ID.:2:&SESSION.:GET_DETAIL_REPORT:NO::P2_VALUE:' 
       || TO_CHAR(TRUNC(date1, 'MM'), 'MM') LINK, 
       To_CHAR(TRUNC(DATE1, 'MM'), 'MM/YYYY') valeur, 
       sum(valeur) "Cumul"
       FROM PL_MF_JOUR
WHERE  cle = :P2_DEPT
AND    DATE1
BETWEEN to_date('01/01' || :P2_DATE_DEBUT || ' 00:00:00', 'DD/MM/YYYY HH24:MI:SS')
AND     to_date('01/01' || :P2_DATE_DEBUT || ' 23:59:59', 'DD/MM/YYYY HH24:MI:SS') +364
GROUP BY TRUNC(DATE1, 'MM')
ORDER BY TRUNC(DATE1, 'MM')
Kind regards

Christian

PS: your help is very appreciated every time, thank you.

You need to generate your calendar of 12 months and then left outer join with it.

Something like:

WITH dts as (select to_date('01/'to_char(rownum,'fm99')||'/'||:P2_DATE_DEBUT,'DD/MM/YYYY') as dt
             from dual connect by rownum <= 12)
SELECT 'f?p=&APP_ID.:2:&SESSION.:GET_DETAIL_REPORT:NO::P2_VALUE:'
       || TO_CHAR(dt, 'MM') LINK,
       TO_CHAR(dt, 'MM/YYYY') valeur,
       sum(valeur) "Cumul"
FROM dts LEFT OUTER JOIN PL_MF_JOUR ON (dt = TRUNC(DATE1,'MM')
                                   AND cle = :P2_DEPT
                                   AND DATE1
                                   BETWEEN to_date('01/01' || :P2_DATE_DEBUT || ' 00:00:00', 'DD/MM/YYYY HH24:MI:SS')
                                   AND     to_date('01/01' || :P2_DATE_DEBUT || ' 23:59:59', 'DD/MM/YYYY HH24:MI:SS')+364
                                   )
GROUP BY dt
ORDER BY dt

NB. Untested (obviously)

Tags: Database

Similar Questions

  • How can I set up Vista so that the PC does not switch to another window (for example the Spy Sweeper alerts) while I am playing a game?

    How can I set up Vista so that the PC does not switch to another window (for example the Spy Sweeper alerts) while I am playing a game?

    Vista is not in control of this technique. Spy Sweeper needs to have an option to control that. If this isn't the case, then it is badly programmed. Flight of focus (go to another window) when it is actually needed is a big no-no for the design. I find this option, if I were you :)

  • How to join start in safe mode when the mouse does not work?

    (I'm on another computer to ask this question). I'm in safe mode; mouse does not work; arrow keys work but don't go to 'start '. How to get started?

    Assuming you have the office showing with all applications minimized or closed, Tab or F6 should pass the Start button and a few other "elements" on the taskbar.  Look closely and you will see a light preview highlighting of the selected item.  Press the Enter key to activate it.

    In XP Safe Mode, the cycle is start button > Quick Launch toolbar > [of any application taskbar icon] > clock > desktop icons.  While the Quick Launch toolbar is highlighted, the arrows move among the icons in the QL toolbar.  While the desktop icon is highlighted, the arrow keys will be touring all the desktop icons.

    Have a look here--> http://support.microsoft.com/kb/301583

  • How can you download pro Prime Minister when the icon does not exist in the clouds? [was: pr]

    How can you download pro Prime Minister when the iucon doesent exist cloud?

    In order to download the software, your computer must meet the system requirements to run the software.

    http://helpx.Adobe.com/x-productkb/policy-pricing/system-requirements-Premiere-Pro.html http://www.Adobe.com/products/premiere/tech-specs.html

    The usual for not being able to download reason is that Premiere Pro (and other video applications such as After Effects) are 64-bit only what they need for a 64-bit computer and a 64-bit operating system.

    If you use a 32-bit computer and operating system, and then you see the icon of Premiere Pro as the software will not work on your computer.

  • How to activate Windows XP - my code on the computer does not work

    I typed in the numbers on my computer to activate Windows, I receive a message to do so.  However, the message indicates this product is not recognized.

    Fidell Stewardson

    Hi man,

    Please see the following article:

    How to activate Windows XP

  • How export/import prefs.js? Copy of the file does not work

    I want to export/import on: configuration changes. The path is "Firefox/Profiles/i63866ho.default-1384517947097/prefs-js". I also copied prefs.js, all the contents of the file "i63866ho.default - 1384517947097" and the folder "Profiles". Nothing has worked. When I copied prefs.js he did nothing and returns to the old/first prefs.js after restarting firefox. When I copy the file it says that it cannot do.

    Can someone help me?

    Thank you very much

    I'm not very familiar with profiles.ini. There are probably other volunteers who can tell you the best way to add the new (old) profile name to the file.

    The prefs.js file is small, but you mentioned the copy of your extensions as well, so I thought it would be more convenient copy the entire folder. I think that if you can afford the disk space, it is easier to grasp this. That said, some of the information is redundant with, for example, the bookmarkbackups folder contains many safeguards dated (mine are over 1 MB). If you use download sites that use IndexedDB (such as the mega), can have a very large folder indexedDB that you really don't need to carry with you.

  • How to retrieve info from my i5c if the screen does not work and the warranty has expired?

    My iphone 5 c screen does not work and my warranty has expired there is 138days. I visited my carrier (AT & T) and contacted the Apple support.

    I want just the information of contact at least if nothing else my phone. What can I do?

    Have you tried to backup with iTunes on your computer?

    Are you also the timing or the iCloud backup device?

  • How to generate a value of variable "fast"? Only possible with dbms_outpu

    Suppose I have defined a variable in a script from SQLplus and want it output in a quick statement.

    How can I do?

    The following does NOT work:

    accept myvar prompt "enter value ="
    prompt & myvar

    Here, I am invited again a second time.

    What can I do else?

    Is dbms_output.put_line (...) the only way?

    Peter
    SQL> accept myvar prompt 'Enter value='
    Enter value=222
    
    SQL> prompt you entered &myvar
    you entered 222
    

    Max
    http://oracleitalia.WordPress.com

  • How to check that the variable 'does not contain' value?

    Hello

    I use CP 7.0.1.237.

    We want to use the widget text box for a custom quiz and verify a response. While we understood how to check the existence of certain key words, we are not able to find a way to check that the content does NOT contain certain keywords. For example, we want to ensure that the text entered in this widget does not contain a "Transformation" and "Non-compliant.

    Is this possible at all?

    Thank you

    Anthony

    Anthony, it works perfectly. Created this conditional action with 4 decisions. I used the interaction of training text scrolling in CP8 (because now you can control the variable - which means I might have a Reset button):

    First decision:

    Second decision (the third is similar to the following)

    Fourth and final decision

    I put the variable words (v_first... v_fifth), it's a reflex I use since I shared actions that much. The variable associated to the ETB (you can now reset an empty var in CP8) is v_TextArea and the Boolean value that will decide if positive feedback (StarOK) should be shown is v_TA_OK. If you want to display a negative feedback, put this in the ELSE part of the final decision.

    FYI: it took 15 minutes, including the creation of assets and the variables and tests. Personally I would have needed more time to do it in JS, but that's just me.

    Lieve

  • I can't create an installer, after install the Vision Builder demo and then uninstall it. I can't create a Labview Installer more, he asks me an installer of generator of Vision, even if Labview my program does not have nothing to do with it...

    I can't create an installer on LabView, after install the Vision Builder demo and then uninstall it. I can't create a Labview Installer more, he asks me an installer of generator of Vision, even if Labview my program does not have nothing to do with it...

    Hi, Shada, this can happen if you include additional installers to your installer for example DAQmx. When you do this the installation program must include other files like MAX (Measuremente and Automation Explorer). Probably when you installed Vision Builder he updated MAX, so when your Installer try to understand MAX, his request the source where it was installed in your computer in this case Vision Builder.

    Here you can cache information so it is not asked once again, or you can download a version more recent fo DAQmx, then it will update MAX and change the dependecy.

    You can find more details about it in this KB:

    3S88PJMY knowledge base: why do I get an error message 'Missing Distribution' when you try to build an install...

    And to keep a copy, here's more information:

    How to stop missing delivery Notification whenever I build an installer?

    Best regards

  • How do I run a script only if the field is not empty

    How do I run a script only if the field is not empty

    Well well, thanks to you, I had a full date on separate days, the months and the years in different areas. But now, I have a problem, as PDF has several fields calculated with script if you enter the date calculated by all other areas, which have separated and undefinied gives me does not want to put this to not always use this field. I tried to put one conditional if else but I sale. Esto, this is what I'm wearing

    var datesol = event.value;//declaramos the variable

    If (datesol = "") {}

    this.getField('yearsol').value = "";

    this.getField('monthsol').value = "";

    this.getField('daysol').value = ""}

    else {}

    var array_datesol = datesol.split("/"); / / separamos esa con date the split funcio

    this.getField('yearsol').value = array_datesol [2];

    this.getField('monthsol').value = array_datesol [1];

    this.getField('daysol').value = array_datesol [0];

    With what they do not separate them now.

    Help please

    As mentioned, you cannot use

    If (datesol = "")

    because that sets the value of datesol to «» (you will need to double for the comparison operator =)

    If you want to run code only if it is NOT empty, while it takes:

    If (datesol <> "")

  • I mistakenly checked the box "don't show me this message again" on the Script does not have attention... How can I bring back?

    Hi and thanks for reading my question,

    I recently got a pop up box "warning: the Script does not" Firefox v38.0 and checked by mistake the box (paraphrase) "don't show me this message again."

    How can I report these warnings? I saw something in the tools-> Options area... have I missed?

    Thank you!

    You can check these prefs on the topic: config page and if either appears "BOLD" (user set) (bold) then right click in the pref and click Reset.

    You can open the topic: config page via the address bar.
    You can accept the warning and click on "I'll be careful" to continue.

  • After hiighlighting a Word and paste it into another document, the Clipboard does not; When I hit enter again and again blocks. How should I do?

    When I select a word or phrase and copy to the Clipboard, then paste it into another area of the Clipboard does not erase the expression. Therefore, every time that I type and press the Enter key it continues paste the sentence throughout my document. I have the latest download of Firefox are installed (16.0, win 7 and that's when it started.) How to stop this heinous behavior so I can type a sentence with normality?

    Louise

    Try Firefox Safe mode to see how it works there.

    A way of solving problems, which disables most of the modules.

    The problems of Firefox using Firefox SafeMode

    When in Safe Mode...

    • The State of plugins is not affected.
    • Custom preferences are not affected.
    • All extensions are disabled.
    • The default theme is used, without a character.
    • userChrome.css and userContent.css are ignored.
    • The layout of the default toolbar is used.
    • The JIT Javascript compiler is disabled.
    • Hardware acceleration is disabled.
    • You can open the mode without failure of Firefox 15.0 + by pressing the SHIFT key when you use the desktop Firefox or shortcut in the start menu.
    • Or use the Help menu option, click restart with the disabled... modules while Firefox is running.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before using the shortcut of Firefox (without the Shift key) to open it again.

    If it's good in Firefox Safe mode, your problem is probably caused by an extension, and you need to understand that one.

    http://support.Mozilla.com/en-us/KB/troubleshooting+extensions+and+themes

    When find you what is causing that, please let us know. It might help others who have this problem.

  • Firefox continues to try to update each time I open the browser, and it then puts a message saying update failed. It does this on both of my computers. The most recent version, the other does not. How can I stop Firefox to do this?

    Firefox continues to try to update each time I open the browser, and it then puts a message saying update failed. It does this on both of my computers. We already have the latest version, the other does not. How can I stop Firefox to do this?

    If there are problems with the implementation at day then best is to download the full version and uninstall the currently installed version and remove the Firefox program folder to remove all remaining files.

    Download a new copy of Firefox and save the file to the desktop.

    Uninstall your current version of Firefox, if possible.

    • Do NOT remove the data of a personal nature when you uninstall the current version or you lose your bookmarks and other data, because all profile files will be deleted.

    Delete the program folder Firefox before installing newly downloaded copy of the Firefox installer.

    Your bookmarks and other profile data stored in the Firefox profile folder and will not be affected by a relocation, but make sure that you do not select delete data of a personal nature if you uninstall Firefox.

  • How to lock my iPhone 6's screen so it does not move between portrait and landscape?

    How to lock my iPhone 6's screen so it does not move between portrait and landscape?

    Select portrait orientation lock.

    Swipe the top of your home screen to access the control center and select the icon with a lock and an arc around him.

Maybe you are looking for