Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7597463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:09:46+00:00 2026-05-30T22:09:46+00:00

In my Oracle DB, I have a left outer join for a parent workorder

  • 0

In my Oracle DB, I have a left outer join for a parent workorder to its child workorders. I then run a calculation performing a SUM() of some of the child values. I wrap the results from the child workorders in Nvl() to ensure they’ll be calculated correctly.

This works, except when there are no child workorders for the parent. In this case, the “nulls” returned during display are because there are no results in the join, and thus it appears that Nvl([fieldname],0) doesn’t convert them to show 0. Thus, when I think sum the child values with the parent values, they also return null due to adding a value to a null value.

What’s the best way to get around this? Is this something that can be worked around or is it a smell that something is wrong with my query fundamentally?

The Query

Sorry, I’m not able to post a setup for it at the moment. For this specific workorder (hard-coded), the “right hand” part of the join is empty because the parent has no children, and thus displays null.

SELECT *
FROM   (SELECT *
        FROM   R_PCR_ALLWOSANDTASKSSEPARATELY)WOINFO
       LEFT OUTER JOIN (SELECT WORKORDERNUMBER                AS TASKWORKORDRENUMBER
                               , PARENT                       AS TASKPARENT
                               , NVL(TOTALMATESTCOSTFORWO, 0) AS TOTALMATESTCOSTFORWO_TASK
                               , NVL(TOTALLABESTCOSTFORWO,0)         AS TOTALLABESTCOSTFORWO_TASK
                               , NVL(TOTALMATACTCOSTFORWO,0)         AS TOTALMATACTCOSTFORWO_TASK
                               , NVL(TOTALLABACTCOSTFORWO,0)         AS TOTALLABACTCOSTFORWO_TASK
                               , NVL(TOTALLABACTHOURSFORWO,0)        AS TOTALLABACTHOURSFORWO_TASK
                        FROM   R_PCR_ALLWOSANDTASKSSEPARATELY)TASKINFO
         ON ( WOINFO.WORKORDERNUMBER = TASKINFO.TASKPARENT )
WHERE  WORKORDERNUMBER = '2826059'; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:09:47+00:00Added an answer on May 30, 2026 at 10:09 pm

    You need to apply NVL after the results are returned by LEFT join.

    Try this:

    SELECT  WOINFO.*
                    , TASKWORKORDRENUMBER
                    , TASKPARENT
                    , NVL(TOTALMATESTCOSTFORWO_TASK,0) AS TOTALMATESTCOSTFORWO_TASK
                    , NVL(TOTALLABESTCOSTFORWO_TASK,0) AS TOTALLABESTCOSTFORWO_TASK
                    , NVL(TOTALMATACTCOSTFORWO_TASK,0) AS TOTALMATACTCOSTFORWO_TASK
                    , NVL(TOTALLABACTCOSTFORWO_TASK,0) AS TOTALLABACTCOSTFORWO_TASK
                    , NVL(TOTALLABACTHOURSFORWO_TASK,0) AS TOTALLABACTHOURSFORWO_TASK
    FROM   R_PCR_ALLWOSANDTASKSSEPARATELY WOINFO
           LEFT OUTER JOIN (SELECT WORKORDERNUMBER                AS TASKWORKORDRENUMBER
                                   , PARENT                       AS TASKPARENT
                                   , TOTALMATESTCOSTFORWO_TASK
                                   , TOTALLABESTCOSTFORWO_TASK
                                   , TOTALMATACTCOSTFORWO_TASK
                                   , TOTALLABACTCOSTFORWO_TASK
                                   , TOTALLABACTHOURSFORWO_TASK
                            FROM   R_PCR_ALLWOSANDTASKSSEPARATELY) TASKINFO
             ON ( WOINFO.WORKORDERNUMBER = TASKINFO.TASKPARENT )
    WHERE  WORKORDERNUMBER = '2826059'; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Materialized view in Oracle that contains a LEFT JOIN which takes
I have one issue with retrieval Parent/Child relationship of type Folder Hierarchy Ideally, in
I have Oracle SQL Developer already installed and am able to connect to and
We have Oracle Server Oracle Version: 10.2.0.4.0 - 64bit. I like to connect to
I am running oracle and have a query which pulls some results from the
I have an Oracle server (version 9, I believe) and a MS SQL server
I have an Oracle database backup file (.dmp) that was created with expdp .
I have an Oracle table which contains event log messages for an application. We
I have an Oracle database and the boolean fields are CHAR(1) with Y/N stored.
I have a Oracle database and one of the fields is a date range

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.