sum of cases does not not pls help

Hi all

I have the following query with me
select case when F.ITEM_UOM = 'Cubic Feet' then
            ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/H.SLURRY_YIELD))
        when F.ITEM_UOM =  'Pound' then
            ceil((ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/DECODE(H.SLURRY_YIELD,0,NULL,H.SLURRY_YIELD)))*94)*F.ITEM_PERCENT/100 )
          when F.item_uom='Gallon'
     THEN ceil(ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/DECODE(H.SLURRY_YIELD,0,NULL,H.SLURRY_YIELD)))*F.ITEM_PERCENT )
       end MAT_ACT,E.MANUAL,
       e.opn_job_desc,e.invoice_ref,e.invoice_ref_m,f.item_number,f.item_name,f.item_uom,f.description,J.OPN_VALUE
     FROM xxnp_opn_joblog_001 E,
          XXNP_OPN_JOBLOG_EST_002   F,
          XXNP_OPN_JOBLOG_STAGE_002 G,
          XXNP_OPN_JOBLOG_SLURRY_003 H,
            XXNP_OPN_JOBLOG_RES_005 J
      WHERE E.OPN_JOB_DESC   = E.OPN_JOB_DESC AND E.MANUAL='N'
       and J.opn_resource_desc='4X4  PICK-UP OR LIGHT VEHICLES'
        AND E.OPN_JOBLOG_001_ID = J.OPN_JOBLOG_001_ID 
      AND E.OPN_JOBLOG_001_ID = G.OPN_JOBLOG_001_ID
        AND G.OPN_JOBLOG_006_ID = H.OPN_JOBLOG_006_ID
        AND H.OPN_JOBLOG_007_ID = F.OPN_JOBLOG_007_ID
        AND G.OPN_JOBLOG_006_ID = H.OPN_JOBLOG_006_ID
        AND H.OPN_JOBLOG_007_ID = F.OPN_JOBLOG_007_ID

i require these two columns(1) [sum(case stmnt of cubicfeet)*0.047+sum(case stmnt ofpound)*0.0005]*(distance/2)as COL1
            (2)SUM(case stmnt of cubic feet )as CUFT
so i did this as given below but the values are not getting summed :(
distance/2 is J.OPN_VALUE/2

select round((sum(case when F.ITEM_UOM = 'Cubic Feet' then
            ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/H.SLURRY_YIELD ))else 0 end)*0.047
       +sum(case when F.ITEM_UOM =  'Pound' then
            ceil((ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/DECODE(H.SLURRY_YIELD,0,NULL,H.SLURRY_YIELD)))*94)*F.ITEM_PERCENT/100 )else 0 end)*0.0005)*
               (J.OPN_VALUE/2))COL1,sum(case when F.ITEM_UOM = 'Cubic Feet' then
            ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/H.SLURRY_YIELD ))else 0 end)CUFT,
                e.opn_job_desc,e.invoice_ref,e.invoice_ref_m,f.item_number,f.item_name,f.item_uom,f.description,J.OPN_VALUE
     FROM xxnp_opn_joblog_001 E,
          XXNP_OPN_JOBLOG_EST_002   F,
          XXNP_OPN_JOBLOG_STAGE_002 G,
          XXNP_OPN_JOBLOG_SLURRY_003 H,
            XXNP_OPN_JOBLOG_RES_005 J
      WHERE E.OPN_JOB_DESC   = E.OPN_JOB_DESC AND E.MANUAL='N'
       and J.opn_resource_desc='4X4  PICK-UP OR LIGHT VEHICLES'
        AND E.OPN_JOBLOG_001_ID = J.OPN_JOBLOG_001_ID 
      AND E.OPN_JOBLOG_001_ID = G.OPN_JOBLOG_001_ID
        AND G.OPN_JOBLOG_006_ID = H.OPN_JOBLOG_006_ID
        AND H.OPN_JOBLOG_007_ID = F.OPN_JOBLOG_007_ID
        AND G.OPN_JOBLOG_006_ID = H.OPN_JOBLOG_006_ID
        AND H.OPN_JOBLOG_007_ID = F.OPN_JOBLOG_007_ID
group by  e.opn_job_desc,e.invoice_ref,e.invoice_ref_m,f.item_number,f.item_name,f.item_uom,f.description,J.OPN_VALUE
kindly help me to register the two above columns COL1 CUFT AND my first request

thanking in advance


concerning
oracleuser

Published by: makdutakdu on January 28, 2010 08:22

Published by: makdutakdu on January 28, 2010 11:33

My mistake

select ROUND((sum(case when item_UOM = 'Cubic Feet' then mat_act else 0 end)*0.047
       + sum(case when item_uom = 'Pound' then mat_Act else 0 end)*0.0005)*(OPN_VALUE/2)) col1
, opn_job_desc,OPN_VALUE, sum(case when item_uom = 'Cubic Feet' then mat_act else 0 end) ol2
from (
select case when F.ITEM_UOM = 'Cubic Feet' then
            ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/H.SLURRY_YIELD))
        when F.ITEM_UOM =  'Pound' then
            ceil((ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/DECODE(H.SLURRY_YIELD,0,NULL,H.SLURRY_YIELD)))*94)*F.ITEM_PERCENT/100 )
          when F.item_uom='Gallon'
     THEN ceil(ROUND(((H.SLURRY_VOL_ACTUAL * 5.6146)/DECODE(H.SLURRY_YIELD,0,NULL,H.SLURRY_YIELD)))*F.ITEM_PERCENT )
       end MAT_ACT,E.MANUAL,
       e.opn_job_desc,e.invoice_ref,e.invoice_ref_m,f.item_number,f.item_name,f.item_uom,f.description,J.OPN_VALUE
     FROM xxnp_opn_joblog_001 E,
          XXNP_OPN_JOBLOG_STAGE_002 G,
          XXNP_OPN_JOBLOG_SLURRY_003 H,
            XXNP_OPN_JOBLOG_RES_005 J,
            XXNP_OPN_JOBLOG_EST_002   F
           left outer join
            MTL_SYSTEM_ITEMS_FVL P on
                  F.ITEM_NUMBER=P.SEGMENT1 AND
          F.ITEM_NAME=P.SEGMENT2 AND F.ITEM_UOM=P.PRIMARY_UNIT_OF_MEASURE
      where E.OPN_JOB_DESC   = E.OPN_JOB_DESC AND E.MANUAL='N'
       and J.opn_resource_desc='4X4  PICK-UP OR LIGHT VEHICLES'
        AND E.OPN_JOBLOG_001_ID = J.OPN_JOBLOG_001_ID
      AND E.OPN_JOBLOG_001_ID = G.OPN_JOBLOG_001_ID
        AND G.OPN_JOBLOG_006_ID = H.OPN_JOBLOG_006_ID
        AND H.OPN_JOBLOG_007_ID = F.OPN_JOBLOG_007_ID
        AND G.OPN_JOBLOG_006_ID = H.OPN_JOBLOG_006_ID
        AND H.OPN_JOBLOG_007_ID = F.OPN_JOBLOG_007_ID) group by opn_job_desc,OPN_VALUE

It really because it is very difficult to write the query without table structure, data not just based on the imagination.

Concerning

Tags: Database

Similar Questions

  • CAPTCHA does not. have tried all the solutions support and installed the new FF. still does not. Help.

    CAPTCHA does not. have tried all the solutions support and installed the new FF. still does not. Help.

    Try creating a new profile as a test to check whether your profile is the source of the problems.

    See "basic troubleshooting: a new profile:

    There may be extensions and plugins installed by default in a new profile, so check that in "tools > Modules > Extensions & Plugins" in case there are still problems.

    If the new profile works then you can transfer files from the old profile to the new profile, but make sure not to copy corrupted files.

    See:

  • I DOWNLOADED FLASH PLAYER BUT WHEN I TRY TO WATCH A CLIP IT IS SAID TO GET FLASH PLAYER, I HAVE ALREADY. I CONTINUE TO DOWNLOAD, BUT IT DOES NOT ALWAYS HELP

    Question
    I DOWNLOADED FLASH PLAYER BUT WHEN I TRY TO WATCH A CLIP IT IS SAID TO GET FLASH PLAYER, I HAVE ALREADY. I CONTINUE TO DOWNLOAD, BUT IT DOES NOT ALWAYS HELP. Thank you

    --> Updated Firefox to version 10.0.1

    Follow the suggestions mentioned in the section "Flash does not work properly or will not update" in the following article:

    Check and tell if its working.

  • How to free download of iMovie because MacBook Pro is supposed to be free, but I'm not. pls help

    How to free download of iMovie because MacBook Pro is supposed to be free, but I'm not. pls help

    You can download the latest version of iMovie for free only if you already have iMovie 9 joined to your Apple ID.  It comes free with new Macs to the first owner.

    Geoff.

  • DVD player does not? Help!

    DVD player does not? Help!

    See the Article KB

    Have you tried VLC Media Player?

  • tried everyting to sort the "assertion failed" in LightroomCC, uninstall and installed it again, tried to check the photo folder in the user account, it still does not, PLEASE HELP!

    Had "assertion failure" at the launch of LightroomCC, tried everything help, uninstall and installed it again, tried to check the photo in the user account folder, still does not, PLEASE HELP!

    Thanks for the help.

    My computer scientist has created a new user in my computer and now the 6 Lightroom

    works very well.

    Thank you

  • Comparison of simple table does not. Help, please!

    I struggled with this problem for a few days now, and I'm slowly losing my mind.

    • I am in Adobe Acrobat 10.
    • I have a field called button group: btn0, btn1, btn2, etc..
    • I have a band called text fields: txt0, txt1 txt2, etc..
    • I have a script that takes the value of txt0 and makes the legend of btn0 and so on.
    • I have a script that sets the btn0 to setFocus txt0 MouseUp action, and so on.
    • These scripts work very well.
    • I have a script that takes values of all fields txt and sort puts them in a table.
    • I have a script that takes the array element [0] and makes the legend of btn0 and so on (alphabetical list of buttons).
    • These scripts work very well.
    • I am trying to compare the value of the array element [0] to each field txt to find the match, then set the action MouseUp btn0 to setFocus to the corresponding txt field, and so on (until my alphabetical list points to the correct location).
    • It is here where I am at a loss.

    Here's what I have:

    specified fields txt

    txt0 var = this.getField ("name of Z");

    txt1 var = this.getField ("name");

    etc.

    put their values in an array named rxArray

    var rxArray = [txt0.value, txt1.value]; etc.

    sort the table

    rxArray.sort ();

    Set the legends on the sorted array elements

    for (var i = 0; i < 5; i ++) {}

    var b = ("btn" + i);

    this.getField (b) .buttonSetCaption (rxArray [i]); works very well; sort by alphabetical order of the list of buttons

    Here is what goes wrong

    for (var x = 0; x < 5; x ++) {}

    var r = ("txt" + x);

    If (rxArray [i] == r.value) {}

    var s = (r + ' ". setFocus();" ');

    this.getField (b) .setAction ("MouseUp", s);

    }

    }

    }

    end

    Here's what I know:

    Alphabetical order and labeling works very well, but the MouseUp scripts to buttons work at all. Nothing happens.

    If I change the piece next to the above script:

    If (rxArray [i] == r.value) {}

    var s = (r + ' ". setFocus();" ');

    this.getField (b) .setAction ("MouseUp", s);

    To do this:

    If (rxArray [i] == txt1.value) {}

    var s = (r + ' ". setFocus();" ');

    this.getField (b) .setAction ("MouseUp", s);

    Because rxArray [0] is equal to the value of txt1 ("name"), then the MouseUp script for btn0 Gets the value:

    Txt4.SetFocus ();

    So I know that, whenever the nested loop runs, the case statement is true, and the setFocus script updated. Until the end of the loop, leaving the setFocus as last run element. Then why my script does not work? It should only update the setFocus script IF the array element matches the txt field and it is on THIS field of txt.

    Please please help. I know I'm missing something simple somewhere.

    I don't see why you would need tables at all... For example, sortNumber.

    You can essentially all this code replace it with this:

    for (var x = 0; x)< 5;="" x++)="">

    var t = this.getField ("t" + x); the text field

    var b = this.getField ("btn" + x); the button

    b.buttonSetCaption (t.value);

    var s = "this.getField('"+_t.name_+"').setFocus()";

    b.setAction ("MouseUp", s);

    }

    It is the same for the rest of your code as well.

    With respect to the addNew function, you must add a pause command inside the if statement to prevent continue further after the first empty field has been found.

  • Sum of cell does not

    Hi all
    I have the following fields

    the contract number, action_amount, work_order_amnt

    and I'm trying to create the sum of the cell to change the contract number on the two fields amount, but for some reason any its giving only the sum of cell on one of the two fields

    contract_number action_amount work_order_amount
    64066a $1200.00 $800.00
    sum of cell: $1200 cell:
    b 64066 1800.00 $2000.00 $
    sum of the cell: cell $ 1800.00 cum:

    Please, any help is greatly appreciated.

    Thank you

    Hello
    It seems that either you have NULL values in your data, repeating values or that simply cannot be aggregated.

    Try to change the properties of aggregation for the tool and see if that helps.

    If it does not try to set AllowAggregationOverRepeatedValues to 1 in your system preferences.

    If all this fails, you may need to watch your data results one by one including the detail values to know where is the problem. You can find this thread may be useful: Why do not the totals in Desktop?

    Best wishes
    Michael

  • Permissions of third-party software does not. Help, please

    I have a major problem with El Capitan at the moment and I was wondering if anyone can help or has the same problems.

    What happened completely out of the blue and everything was working fine until yesterday to the top. The Mac does not seem to be recognizing my permissions of software. I opened my copy of IK Multimedia Amplitude 4 like I do every day to work and a message pops up saying

    'AmpliTube 4 is not permitted. The 10-day grace period expired. Click OK to start the IK Multimedia Authorization Manager or click Cancel to continue. "I have already registered this product through the Manager of authorization of the IK Multimedia comes out when I install everything first. I've never seen this message before, it is not logical at all! Then I entered the codes of the series in the handler permission again and it fixed the problem (even if it's not necessary) and today I turn on the Mac and the problem has started again.

    Then I went to another application I use every day called Sibelius by Avid. Same thing happened. Then I got the registration codes, and now it seems to be okay. I tried to open another application I use Ableton Live and it says the same thing again. I double click my authorization file that I have to do this and it says that the file is not valid for this computer.

    I'm sure that there is a problem with El Capitan not recognizing my authorization to use the software, I installed. It's too much of a coincidence that 3 3 companies software different all stop working at the same time, right? I called Apple support and they tried to get me to reset the permissions on the apps but it still does not and in the end they told me to contact software manufacturers. If anyone can help I would really appreciate it I use this software for my work and I need their work as soon as POSSIBLE.

    Thank you very much

    Simon

    Unless you have purchased these applications via the Mac App Store, OS X has no mechanism to allow the use of the installed software. This is the license code is written in the app or a license of Add-ons Manager. Licensing may not be compatible with El Capitan, but this is the limit of the participation of El Capitan in the licensing process for these applications.

  • Wireless hardware does not! Help!

    I have a Compaq CQ58.

    Somehow my wireless does not work?

    I had a look on my computer (it is currently running windows 8.1), but he could not find a wireless device. It was running before wireless, but now he can't find the wireless lan device. All he can do is to run Ethernet. I don't know why it does this?

    Can you help me?

    Thank you.

    Hello:

    You see a labeled network controller device in Device Manager?

    If you do, it's the wireless card and he needs of the installed driver for W8.1.

  • HP pavilion dv9925nr sound does not work help please

    Hi I have a hp pavilion dv9925nr laptop and I spent in Windows XP pro and now the sound does not work and iv tried everything iv downloaded all the drivers on the internet and everyone simply goes on to say: no driver no has been supported in this package and its driving me crazy please can someone help before I just use it to target paratactic

    Hello:

    Then I recommend that you follow the instructions in the guide to the link I posted above.

    After you install the MS UAA driver, you may need to install the audio driver updated the posted on this link:

    Conexant High Definition SmartAudio 221 drivers (ModelC700, Vx5xx series and dvx5xx and ABOVE )

    Pilot modded by silver here

    Unzip it to a folder... Use the device, right click "Audio Device on HD" Manager, choose Update driver,
    Not to connect, install from a list or specific location,
    Select don't search, I will choose the driver to install.
    For the hardware Type select 'show all devices '.
    Remove control "Show compatible hardware" and click on 'disk '.
    Next... Navigate to the unzipped folder and choose the "WiSVHe5.inf".
    Ignore XP when he complains, Reboot.

    If none of this works, try to reinstall XP and start from scratch. If you do not see your appliance an audio controller if you reinstall XP, then more than likely it is a hardware failure of the audio chip.

    Paul

  • Services of Windows Vista 64 does not, please help!

    Hi thanks for reading.

    Noticed the other day my firewall is not running. A few weeks ago my AVG anti virus asked me if I wanted to move to a premium account for a 30 day trial and contained their own version of a firewall. He said that he would resort to Windows Firewall when finished.

    30 days passed, and he asked me to return to the original settings and the free version. I don't check if windows firewall started running.

    And so back when I noticed.

    What Ive tried: Panel > Security > windows firewall - says "windows firewall does not use recommended settings to help protect your computer" and there is a button for "update settings now" which when you click on it, I get the thing of glass hour for a few seconds and nothing happens.

    Run > services.msc > Windows Firewall - said State 'arrested' firewall service and when you are prompted to start, gives me error 6801

    Also noticed now that windows update and windows Defender will not be updated. Windows update search updates, but up quickly the code Error 80070426 and once again, to enforce > services > windows update/defender does not work.

    Then in flicking around, I have observed under the information system in 'computer' tab, he says: 'this copy of windows is not activated, click here to activate now' and Im thinking it is crazy! I have not had my PC very long, but I have activated vista right after that I installed it when buying. If I click on the link, and it says: 'a problem occurred when Windows tried to activate. Error code 0x80070426

    Edit: just thought of something that can help. Awhile back, before this all started, windows update prompted me one afternoon to install Service Pack 2 and I thought "why not?" Well, after a complete system failure and me to have my friend rally and he manages to get into the command prompt and run 2 types of checkdisk, I go back to my computer. Now, I don't think it off anything, or whatever it may be disabled, but something could have been damaged?

    IM puzzled and any help would be massively appreciated! If anyone needs more info, let me know!

    System information:

    Vista Home Premium 64-bit
    Intel Core2Duo E8400 2x3ghz
    8 GB RAM

    Kind regards

    A1. See...

    How TO do a clean install of Vista: section "If you want to reinstall Windows Vista by running a new installation...". "of http://windows.microsoft.com/en-us/windows-vista/Installing-and-reinstalling-Windows-Vista#section_3

    Once installed the clean, you will have the equivalent of a "new computer" in order to take care of everything on the page following before otherwise connect the machine to a network or the internet and before using a flash drive or the SD card that is not brand new, or has not been freshly formatted:

    4 steps to help protect your new computer before going online
         http://www.Microsoft.com/security/pypc.aspx

    NB: No matter what Norton or McAfee free trial which is preinstalled on the computer when you bought will be reinstalled (but invalid) when Windows is reinstalled. You MUST uninstall the trial for free and download/run the removal tool before installing updates, Windows Service Packs, or updates IE and before installing your new anti-virus application (which will require WinXP SP3 must be installed).

    Norton Removal Tool
         FTP://ftp.Symantec.com/public/english_us_canada/removal_tools/Norton_Removal_Tool.exe

    McAfee Consumer product removal tool
         http://download.McAfee.com/Products/Licensed/cust_support_patches/MCPR.exe

    A2. Win7 is fabulous in my humble OPINION. You can format the partition and do a clean install of Win7, Yes.

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • D: drive does not, could help you?

    inserted the CD into drive D: as usual, but now this drive does not work.  uninstalled how to reinstall diskless system?  Help, please

    At this point, the judgment of the pc, put off the power, plug the equipment in another IDE connection.

    set the pins plastic jumper accordingly, if the hardware is connected, if these pins

    also (master/slave), once through, the pc to start... XP will reinstall it now as "found new hardware"

    a drivers XP and install auto...

    Also, most cdrom/cdrw/dvd/etc material are updated firmware, go to her Web mfg

    site & install it youre only model number...

  • my account has been hacked had backit is Arabic, I tried to translate does not work help

    Unfortunately my account has been hacked. I have it back now, but it of in the translation of Arabic.Tried, but does not not for the entire site. Please can you help.

    Unfortunately my account has been hacked. I have it back now, but it of in the translation of Arabic.Tried, but does not not for the entire site. Please can you help.

    You did not bother to tell which e-mail program you use. Maybe one of them?
    View all Windows Live and Hotmail questions in the appropriate forum found here:
    http://windowslivehelp.com/

  • 7510 Photosmart HP e-All-in-one: Photosmart 7510 does not, tech help links not working no more.

    My 7510 Photosmart was working fine just a couple of days, but suddenly, I have a problem: he will pretend to be printed, but there are only a few weak gray lines (which do not match with the document being printed).  I tried the links online to HP technical support, but they all fail, with messages such as:

    Internal Server Error - read

    The server has encountered an internal error or misconfiguration and was unable to respond to your request.

    Reference #3.9733fea5.1428886261.1ce573bc

    The ink cartridges are all quite complete, except for the small black - the big one is full.  I got no error message.  I have reset to factory settings, without success.  I was printing a PDF file.  I don't think that the problem is with the computer, because I tried to print with another computer, with the same result.  The computer is a PC, in Windows 8.

    Help!  I need to print an extension with the IRS!

    Hello

    Please try the steps below...

    1 > while the printer is turned on, open the cartridge door. Check if the ramasseherbe moves automatically.

    2 > wait until the printer goes into silence.

    3 > try to manually move the carriage.

    4 > if the carriage does not move, it could be a ramasseherbe jam. You may need to check if there is a paper jam in the field of transport.

    5 > remove print head, close the printer cover. Unlug if power cord back of the printer.

    6 > wait 30 seconds, and then reconnect the power cord to the back of the printer.

    7 > install the print head and cartridges when prompted.

    If you the problem persists, please call HP Tech Support for assistance because he clould be a problem with the print head.

    If you are in the United States, the toll free # is 1-800-474-6836.

    If you're not in the United States, and then connect to www.hp.com , bottom left it is an icon of the world map, click it and then select the region that you belong to, which would then provide the support options for you for this region.

Maybe you are looking for

  • iTunes Mediathek is gray

    Hello I wanted to add some songs from my iTunes to my Diashow Mediathek - but they are all greyed out... Can someone help me?

  • I have three keys that do not, including the return key.

    I have three keys that do not, including the return key. I can't connect from my password is associated with one of these characters. Help, please.

  • the compass sensor not work lenovo vibe s1

    When I tried to use the qibla finder and compass on my s1 vibe Unit recently bought, it is said the magnetic sensor are not workimg. How can I solve this problem?

  • Recover Windows 8.0 on hp pc

    I would like to reinstall my windows 8 pro system, but I have lost my recovery CD. So, how to do a reinstall or recovery of windows 8 and delete all my files, I supported those upward and its ok to remove them. I'm selling this computer because I don

  • Upgrade GPU for XPS 8700

    As the title says, I have a question about the Dell XPS 8700. I wanted to update the graphics card and after browsing through the forum, I think I already know the answer, but would have an EVGA GeForce GTX 960 to adapt and be compatible. The dimensi