My UNION ALL is not enough work - help!

Hi gurus.

I hope one of you fine pro can sort this for me...

I have a script which is currently if there is an employee number to double but NOT if there is a double number of NOR - what code should I include?
      SELECT DISTINCT per.person_id, per.business_group_id, per.last_name,
                      per.start_date, per.date_of_birth, per.email_address,
                      LPAD(per.employee_number,8,'0') employee_number,
                      per.first_name,
                      per.marital_status, per.middle_names, per.nationality,
                      per.national_identifier, per.sex, per.title,
                      padd.address_id, padd.primary_flag, padd.address_line1,
                      padd.address_line2, padd.address_line3,
                      padd.town_or_city, padd.postal_code,
                      padd.telephone_number_1, paas.assignment_id,
                      paas.assignment_number, paas.object_version_number,
                      paas.effective_start_date, paas.effective_end_date,
                      paas.job_id, paas.position_id, paas.location_id,
                      paas.organization_id, paas.assignment_type,
                      paas.supervisor_id, paas.default_code_comb_id,
                      paas.set_of_books_id, paas.period_of_service_id
                 FROM per_all_people_f per,
                      per_all_assignments_f paas,
                      per_addresses padd
               
                  WHERE padd.person_id = per.person_id
                  AND paas.person_id(+) = per.person_id
                      AND TRIM (LEADING '0' FROM per.employee_number) = TRIM (LEADING '0' FROM :p_emp_number)
                      AND per.national_identifier <> :p_ni_number 
                      
                      
                        UNION ALL
          
          
            SELECT DISTINCT per.person_id, per.business_group_id, per.last_name,
                      per.start_date, per.date_of_birth, per.email_address,
                     LPAD(per.employee_number,8,'0') employee_number,
                      per.first_name,
                      per.marital_status, per.middle_names, per.nationality,
                      per.national_identifier, per.sex, per.title,
                      padd.address_id, padd.primary_flag, padd.address_line1,
                      padd.address_line2, padd.address_line3,
                      padd.town_or_city, padd.postal_code,
                      padd.telephone_number_1, paas.assignment_id,
                      paas.assignment_number, paas.object_version_number,
                      paas.effective_start_date, paas.effective_end_date,
                      paas.job_id, paas.position_id, paas.location_id,
                      paas.organization_id, paas.assignment_type,
                      paas.supervisor_id, paas.default_code_comb_id,
                      paas.set_of_books_id, paas.period_of_service_id
                 FROM per_all_people_f per,
                      per_all_assignments_f paas,
                      per_addresses padd
               
                  WHERE padd.person_id = per.person_id
                  AND paas.person_id(+) = per.person_id
                      AND TRIM (LEADING '0' FROM per.employee_number) = TRIM (LEADING '0' FROM :p_emp_number)
                      AND per.national_identifier = :p_ni_number; 
Thank you very much...

Steven

Hello

JackyWhite wrote:
.. the first section is scheduled to end with

 AND per.national_identifier <> p_ni_number 

but for some reason any of this is not displayed on the screen.

Do you mean it is supposed to be an inequality raise it after per.national_identifier and before p_ni_number ?
This site do not display the operator <>, even inside code tags.
When posting on this site, always use the other inequality operator! =. There is no difference in performance.
>

Its mainly because I need to put a RC in the script but could not because of the outer join if it was to be a UNION all operation This is why the half you get first a <> p_ni_number and the second you get an AND per.national_identifier = p_ni_number;...

The restriction OR applies only to outer join conditions. In other words, you can not say

WHERE   paas.person_id (+) = per.per.person_id
OR      pass.fubar (+)     = per.fubar

(You can do this by using the notation ANSI; just one of the many reasons we syntax ANSII).
However, you can use OR other conditions; for example:

WHERE   paas.person_id (+) = per.per.person_id
AND     (   per.national_identifier != p_ni_number
        OR  per.national_identifier  = p_ni_number
        )

which seems to be what you're trying to do. Moreover, the WHERE clause above is equivalent to

WHERE   paas.person_id (+) = per.per.person_id
AND     per.national_identifier IS NOT NULL
AND     p_ni_number             IS NOT NULL

Whenever you need help, post a few examples of data (CREATE TABLE and INSERT statements), and desired results based on these data to the format.
Simplify as much as possible. For example, your actual query may involve 35 columns, but display only the columns used in the conditions, as well as maybe one more column per table. After that you have a solution for the simplest prioblem, adding that the other columns will be triviial.

Tags: Database

Similar Questions

  • Everio Media Browser... not enough work space, check the ability of the workspace specified in the preference settings

    is it possible to get the movies stored in my lap top which is not on my PC dvd writer that has a dvd burner? Everio Media Browser is the program, I am happy to buy an external burner, but I am concerned about the prompt that appears when I click on "written strt" it would be simply because my laptop is not a dvd burner?

    Hello

    You should check into the Everio browser settings to check the ability of the data you are trying to burn. You should be able to move the DVD to the new PC.

  • Edge not enough working hyperlinks

    Hello

    We have built an animation on board and placed in a site of Muse...

    LGA - Archway

    ... the idea is to click on the blue buildings, to take you to the project pages.

    But instead of opening a new page, the hyperlinks open in dashboard page?

    Could someone let me know how to fix this please?

    Thank you
    Simon

    _Blank to open a new page rather than _self.

  • Just downloaded windows 10... Not obvious Digital Editions / does not work help!

    Just downloaded windows 10 and Digital Editions not clear / work help!

    Don't know why, but I revisited the problem and it seemed no no no program ADE so I thought I would try a new download. Program Setup completed and then low and here is one of my appeared on the screen! Seems to work very well it's version 3 I don't know what I was running previously. I hate computers. Thank you for your interest if Happy New Year Robin.

  • I have rebuilt my laptop Gateway MX6625, did not drive recovery, is went to the gateway web site, all the drivers have worked except the multimedia sound. The gateway was no help, they told her, but the there does not work

    I have rebuilt my laptop Gateway MX6625, did not drive recovery, is went to the gateway web site, all the drivers have worked except the multimedia sound. The gateway was no help, they told her, but the there does not work

    Hello JesusVigo,

    Thank you for visiting the Microsoft answers community.

    Have you tried to use the disk of Windows XP, or Windows Update running default drivers to search for best driver for your sound card?

    Also, I found only 1 driver on your system gateway Web site is located here.

    Hope this helps Chris.H
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • document.getElementById("apexir_APP_USER").value seems to not work on apex 5.0. All spare/solutions solutions would help!

    document.getElementById("apexir_APP_USER").value seems to not work on apex 5.0. All spare/solutions solutions would help!

    @Jorge

    Was able to solve it using document.getElementById("refreshThisRegion_app_user").value. Thank you for your contributions.

  • In time real PXI-1031 does more work with labview. "Not enough disk space to perform the backup.

    The labview real-time project was working until a few weeks ago and the only error that is displayed on the PXI is this error message.

    "NEITHER Configuration Manager: not enough disk space for the backup" everything before that looks like it starts very well. Recently, I removed the hard drive and remove the 4 GB network log file because it seemed to me that a file of 4 GB on a fat32 file system was probably the cause of the problem. After that it the project worked when I tested it, but others in my lab said it was broken again the next day.

    Any help would be greatly appreciated because I don't know all that equipment.

    I found that I had "reset IP" set to "yes" in the bios that seemed to be causing my problem because I changed it to no and it seems to work perfectly now. Sorry that it took so much time to understand and I feel like a fool.

  • I'm running win7 ultimate 64 bit on an hp Pavilion 6630f model when I try to install flash player 17 he won't let me and told me that there is not enough disk space, but after checking, I see I have more than enough 67 gb free. any help would be appreciat

    I had it installed and when I tried to update, it gave me same message. so I uninstalled and tried to reinstall flash player 17 again and same problem, saying I don't have enough disk space

    My problem fixed.

    M_Vargas thank yo for each of you to put and all the other people who pitched in., I really appreciate the help and opinions. problem taken care of. I uninstalled Adobe Flash Player restarted 17 he tried once more with the facility and the same thing... uninstalled once more ran my ccleaner and restore my computer to an earlier time of 1 week. Recharged system went to the Adobe Web and download Flash Player site once more and it has installed, installed fine. rebooted the system and on the next reboot it ask me if I wanted to update my Flash drive I clicked on Yes. Downloaded and this time it installed the up date very well with no (not enough disk space) Message. It was my dose to the Situation and the only thing I could think of and cela worked. So, I hope it helps someone in the future that would have met this problem or the Situation. Once again thanks M_Vargas and Jean-Luc for your help and your contribution in this case of mine.

  • Not enough space on the data store.  Newb help please.

    I have a running ESXi 4.1.0 2 Windows VMs server.  Everything worked very well, but I had to turn off all of the server and physically move.  When I powered it back, only on virtual machines with the power on at the same time.  The other dies with the error above.  I have very little experience with VMware and I'd appreciate any help.  Thank you.

    Welcome to the community - the reason why you can't turn on your VM is because a vmkernel swap file is created when you turn on the virtual machine, and if there is not enough space, then, you will receive this error - you'll need clean the directories where are installed the virtual machines - you'll need to remove all of the log files If there are snapshots commit those and then you should be able to powere on virtual machines

  • I just reinstalled Adobe Acrobat X 1 and I can't save files PDF that is sent to me. I just get "this document cannot be saved. There is a problem reading this document (21)"and then when I click OK I get 'not enough for the image' help!

    I just reinstalled Adobe Acrobat X 1 and I can't save files PDF that is sent to me. I just get "this document cannot be saved. There is a problem reading this document (21)"and then when I click OK I get 'not enough for the image' help!

    More information on this issue can be found here:

    https://forums.Adobe.com/thread/1672655

    A "quick" fix that worked for me was to uninstall Adobe... and download Adobe Reader 11.0 installation base.

    Then download each individual updates and run them sequentially.

    I installed back to the last update of security which is version 08 and were able to register under normal operations.

    You will need to disable the automatic updates to keep up with the 08 version, until Adobe fixes this problem in a future release.

    http://www.Adobe.com/support/downloads/product.jsp?product=10&platform=Windows

    Adobe Reader 11.0 - installer multilingual (MUI) AdbeRdr11000_mui_Std

    Adobe Reader 11.0.01 update - installer multilingual (MUI) AdbeRdrUpd11001_MUI.msp

    Adobe Reader 11.0.02 update - all languages AdbeRdrSecUpd11002.msp

    Adobe Reader 11.0.03 update - installer multilingual (MUI) AdbeRdrUpd11003_MUI.msp

    Adobe Reader 11.0.04 update - installer multilingual (MUI) AdbeRdrUpd11004_MUI.msp

    Adobe Reader 11.0.05 - all languages AdbeRdrSecUpd11005.msp security update

    Adobe Reader 11.0.06 update - installer multilingual (MUI) AdbeRdrUpd11006_MUI.msp

    Adobe Reader 11.0.07 update - installer multilingual (MUI) AdbeRdrUpd11007_MUI.msp

    Adobe Reader 11.0.08 - all languages AdbeRdrSecUpd11008.msp security update

  • [8i] need help on query with a subquery/inline using UNION ALL view

    OK, first of all let's start with some background info:
    (1) I work in 8i
    (2) some samples for my problem (please excuse the additional columns of data not used to this problem; I already had the sample laying around tables):
    CREATE TABLE     vbom
    (
         part_nbr     char(25)     
    ,     bom_doc_nbr     char(25)     
    ,     bill_level     number          
    ,     comp_part_nbr     char(25)     
    ,     qty_per          number
    );
    --technically has primary and foreign keys, but whatever...
    --part_nbr is your top level (0) parent
    --comp_part_nbr is the specific child
    --bom_doc_nbr is the parent of the child (comp_part_nbr) and may be either part_nbr or a child of part_nbr that is also a parent
    
    INSERT INTO vbom
    VALUES ('SAMPLE-1','SAMPLE-1', 1,'SAMPLE-2',1);
    
    CREATE TABLE     rqmt
    (
         comp_part_nbr     char(25)     
    ,     prnt_part_nbr     char(25)
    ,     ord_nbr          char(10)     
    ,     sub_ord_nbr     char(3)
    ,     qty_reqd     number
    ,     qty_issued     number
    ,     date_reqd     date
    ,     rqmt_stat     char(2)
    ,     rqmt_type     char(2)
    );
    
    INSERT INTO rqmt
    VALUES ('SAMPLE-1','','S0000TEST1',001,30,0,TO_DATE('06/01/2010','mm/dd/yyyy'),'AL','ID');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000054963',001,15,10,TO_DATE('04/01/2010','mm/dd/yyyy'),'CL','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000032562',001,5,5,TO_DATE('04/15/2010','mm/dd/yyyy'),'IS','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000022341',001,5,4,TO_DATE('04/20/2010','mm/dd/yyyy'),'SH','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000043469',001,10,0,TO_DATE('04/30/2010','mm/dd/yyyy'),'AL','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000071235',001,10,0,TO_DATE('05/01/2010','mm/dd/yyyy'),'OP','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000061224',001,5,0,TO_DATE('05/15/2010','mm/dd/yyyy'),'FP','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000033294',001,5,0,TO_DATE('05/25/2010','mm/dd/yyyy'),'PL','DD');
    So, my first question was that I needed to find in the table RQMT who corresponded with everything on my VBOM have vbom.part_nbr table ' SAMPLE-1'. '. (Please note, in reality the VBOM table has thousands of rows of data, rather than just the 1 I have planned, some of them sharing the same vbom.part_nbr, others not). In addition to finding all RQMT data corresponding to the vbom.comp_part_nbr to vbom.part_nbr (where vbom.comp_part_nbr = rqmt.comp_part_nbr), I also need to find RQMT data for vbom.part_nbr itself (then, records where vbom.part_nbr = rqmt.comp_part_nbr).

    To resolve this problem, I started with the following query:
    SELECT     v.bill_level          AS bill_lvl
    ,     v.comp_part_nbr          AS component
    ,     v.bom_doc_nbr          AS parent
    FROM     VBOM v
    WHERE     v.part_nbr     ='SAMPLE-1'
    UNION ALL
    SELECT     0               AS bill_lvl
    ,     'SAMPLE-1'          AS component
    ,     NULL               AS parent
    FROM DUAL
    It allows me to add a line to the top of the page parent (vbom.part_nbr), which does not exist in vbom.
    My first question is, is UNION ALL of the best way to do it, or could I do a kind of instruction based on the line number box (or something) that would be better? (in this application, or in the final query)

    Then, I used the above query as a point of view online:
    SELECT     a.bill_lvl
    ,     a.component
    ,     a.parent
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     (
         SELECT     v.bill_level          AS bill_lvl
         ,     v.comp_part_nbr          AS component
         ,     v.bom_doc_nbr          AS parent
         FROM     VBOM v
         WHERE     v.part_nbr     ='SAMPLE-1'
         UNION ALL
         SELECT     0               AS bill_lvl
         ,     'SAMPLE-1'          AS component
         ,     NULL               AS parent
         FROM DUAL
         ) a
    ,     RQMT r
    WHERE     a.component     = r.comp_part_nbr
    The problem here is that I have the same results (7 files) with the above query as I do with:
    SELECT     v.bill_level
    ,     v.comp_part_nbr
    ,     v.bom_doc_nbr
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     VBOM v
    ,     RQMT r
    WHERE     v.comp_part_nbr     = r.comp_part_nbr
    AND     v.part_nbr     = 'SAMPLE-1'
    .. .it does not include RQMT recording for rqmt.comp_part_nbr = "SAMPLE-1'.

    To understand what was going on, I ran:
    SELECT     a.bill_lvl
    ,     a.component
    ,     a.parent
    FROM     (
         SELECT     v.bill_level          AS bill_lvl
         ,     v.comp_part_nbr          AS component
         ,     v.bom_doc_nbr          AS parent
         FROM     VBOM v
         WHERE     v.part_nbr     ='SAMPLE-1'
         UNION ALL
         SELECT     0               AS bill_lvl
         ,     'SAMPLE-1'          AS component
         ,     NULL               AS parent
         FROM DUAL
         ) a
    .. .and I get exactly this that I wait, 1 card for the SAMPLE-2 component and 1 plug for SAMPLE-1 (i.e. the recording I generated with the UNION ALL).

    Then I ran:
    SELECT     r.comp_part_nbr
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     RQMT r
    WHERE     r.comp_part_nbr like 'SAMPLE-%'
    .. .and I get all 8 records, whose SAMPLE-1.

    So, it seems that the problem occurred when I join my opinion RQMT one online, although both separately seem to work very well.

    A point to note: all parts of parent and child may not be appointed in the same way as in my example. SAMPLE-1 could have children of the SAMPLE-2, abc123, 20735, for example.

    Any help on this would be appreciated, thanks!

    Hello

    Concerns of problem by comparing 8 literal characters ' SAMPLE-1' for the 25-character CHAR column that contains "SAMPLE 1".»
    17 spaces including the literal or use LPAD or CAST to 25 characters.
    For example:

    SELECT     a.bill_lvl
    ,     a.component
    ,     a.parent
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     (
         SELECT     v.bill_level          AS bill_lvl
         ,     v.comp_part_nbr          AS component
         ,     v.bom_doc_nbr          AS parent
         FROM     VBOM v
         WHERE     v.part_nbr     ='SAMPLE-1'
         UNION ALL
         SELECT     0               AS bill_lvl
         ,     CAST ('SAMPLE-1' AS CHAR (25))               -- CAST added here
                                      AS component
         ,     NULL               AS parent
         FROM DUAL
         ) a
    ,     RQMT r
    WHERE     a.component     = r.comp_part_nbr
    ;
    

    Is there a reason why you use CHAR instead of VARCHAR2? (One reason other than "I can't change it now.", otherwise said.)

  • Order SQL ORA-00933 not correctly completed, UNION ALL

    I apologize if it's really simple, but it made me turn round...

    I inherited the spaghetti code to fix and revise (550 line sql request sent from VBA). I'm putting it in pieces in the form of views. In the following code, I'm calling two subqueries, which I stored in the form of views (Credit_Report_Exposure_P_Sub_A and Credit_Report_Exposure_P_Sub_B). I have create a UNION of them, and it works fine - until I add a WHERE clause. So:

    ---------------------------------------------------------------------------------
    SELECT
    PROFILENAME,
    months,
    sum

    Of
    Credit_Report_Exposure_P_Sub_A

    UNION ALL

    (SELECT
    ccp_profile_name PROFILENAME,
    VWMONTH month,
    SUM SUM (PSJ_TOTAL_AMOUNT)
    Of
    Credit_Report_Exposure_P_Sub_B
    GROUP by
    VWMONTH,
    ccp_profile_name)
    ------------------------------------------------------------------------------------------

    It works very well, to select the same 3 columns in each subquery (ignoring for a moment the wrong choice of alias 'months' and 'sum').

    But when I add the following WHERE clause:
    ------------------------------------------------------------------------------------------
    WHERE
    month = ' 2008-09'
    ------------------------------------------------------------------------------------------
    I get the error in the subject line - which is not properly completed.

    But: if I comment on each half of the UNION, so the WHERE clause works very well.

    Am I missing something obvious? I tried wrapping the whole of the UNION more in parentheses, and the first clause of the UNION as well, but that only creates more errors on supposed lack of right parens.

    Thanks for any help.

    Hello

    Whenever you have a problem with a query, view query. It is unclear where exactly you added the WHERE clause.

    You don't need parentheses around the second part of the UNION all.

    Half of the effect of the WHERE clause of the will UNION ALL? If both, you must add two times, or do the UNION ALL in a subquery and add the WHERE clause to the query of super.

  • Menu and toolbars, tabs suddenly LARGE, need to reset Firefox, not fixed by eliminating add-ins, only a reset works - help!

    Menu and toolbars, tabs suddenly LARGE, need to reset Firefox, not fixed by eliminating add-ins, only a reset works - help!

    Are you sure that this has not been caused by the Tab Mix Plus?

    Your list of details of the system shows a lot of disabled people with only active TMP extension.

    Have you checked for code in userChrome.css if you use this file to customize the user interface?

    In the Firefox Safe mode, these changes are effective:

    • all extensions are disabled (subject: addons)
    • Default theme is used (no persona)
    • userChrome.css and userContent.css are ignored (chrome in the profile folder file)
    • default toolbars is used
    • JIT JavaScript compilers are disabled
    • hardware acceleration is turned off (Options > Advanced Options > general)
    • plugins are not affected
    • preferences are not affected
  • cannot be synced because there is not enough free space to hold all of the items in the iTunes library

    cannot be synced because there is not enough free space to hold all the items in iTunes (required additional 194.8 MB) library.

    It is not supposed to because I have enough memory on my iPad.

    Help, please

    ckucharek wrote:

    It is not supposed to because I have enough memory on my iPad.

    Not based on what? You have not provided any information as to the amount of space you have left and what is the total capacity of your iPad. He must leave a certain percentage of the free capacity at all times, so if you have a 32GB device and you are up to 2 GB of free storage, which could in fact be severed close... If it says you need to 194.8 MG of free space that would be in addition to the amount that you see as free space.

    It also depends on what you're trying to sync on iTunes as well. What content, apps, songs, etc.

    So... can provide you more details?

  • Help... upgrade to El Captain not enough free space

    My upgrade to Yosemite el captain has been interrupted, and now when I boot it goes directly to the os x Installer and when I try to select my disc to install it says theres not enough of free space...

    When I reboot it just for that again and again and again.

    I tried the following:

    Boot into recovery and boot disk mode by selecting (nothing appears)

    Boot into recovery mode, go to the disc utilities and the repair disc (not help)

    Boot into recovery mode and re - install from there (gives the same error)

    Can I delete files via the terminal?

    Any help appreciated.

    Omni DiskSweeper can show you the exact size and location of all your files. It will be the inventory of your disc from files that occupy more space. It can also give you a fairer read disk space than the Finder or storage tab of the about this Mac. If you want you can even delete files from OmniDisk Sweeper.

Maybe you are looking for

  • Master reset PW does not work, continue to ask after reset

    I forgot to master pw; chrome://pippki/content/ResetPassword.XUL used to reset, indicates reset successful; close FF 24.4.0; restart; FF calls again for the master pw. ./. Mozilla/Firefox/e052w6iw.default/signons.SQLite deleted./. Mozilla/Firefox/e05

  • How I locked Siri?

    I've disabled Siri in the menu and restarted my ATV 4. She always Announces each press the button, the title of the song and photo screensaver. Is it possible to put an end to that?

  • Support for song in last OR-IMAQdx data

    Vision Acquisition software, March 2010 edition, came with a nice novelty. Supported data piece for GigE Vision cameras, point 3.6 IMAQdx. This is a feature I've been waiting for for a while, so I gave it a try with my camera Basler Runner. I put in

  • Replaced hard drive. Now USB ports do not work.

    My hard drived has crashed and my local computer guy took my external drive and used in my computer to replace the drive crashed.  Everything seems to work fine, but today, I realized that the USB ports on the front of my computer do not work.  There

  • Windows Vista, suspended from the update

    Hello. I installed the updates last night. Woke up this morning to configure updates. Past stage 0 in step 3, and then is returned from stage 0 to stage 3.  Has been suspended in 100% of phase 3 now for at least 45 minutes. (I took a walk during that