Union all with addistional field

Hello

Maybe this is a stupid question.

I have two tables with 22 columns.

Another table with 23 columns

I want to combine these two tables using union all.

In the first picture, I want back "NA" as the last field.

In the second table, last column is varchar2.

Instead of every column one by one and if I use select * in two queries and add "NA" to one?

I want the union two queries can order and use it with the clause to retrieve values based on conditions somany.

So I have to specify the names of column three times.

I use oracle 10g

Hello Krishna,

Try

select t1.*, 'NA' as  from table1 t1
union
select t2.* from table2 t2;

concerning

Kay

Tags: Database

Similar Questions

  • Can you please help me and Union all with example

    Hi all

    can you please let me know what is the difference between the union and all the.

    It is a general SQL question is better asked in the forum SQL and PL/SQL

  • Relating to the creation of a graph, get an error with a statement "Union All".

    Hello

    I have some data in the table with the following fields;

    Product, Jul-08 Aug-08, Sep - 08 etc. to Jan - 10.

    The PRODUCT field is text showing many product names

    The month of Jul-08 & others have numbers by product that must be aggregated for this month & plotted on the graph of the line.

    My SQL to create the first point on the chart is as below;

    Select the link null, label, SUM(JUL-08) "FFF".
    of "SCHEMANAME." "' TABLENAME '.
    WHERE PRODUCT = "FFF".
    PRODUCT GROUP
    ORDER BY PRODUCT

    It works fine until I want to add the second point of this graphic line by using a "union all" join as follows:

    Select the link null, label, SUM (JUL_08) "FFF".
    of "SCHEMANAME." "' TABLENAME '.
    WHERE PRODUCT = "FFF".

    UNION ALL

    Select the link null, label, SUM (AUG_08) "FFF".
    of "SCHEMANAME." "' TABLENAME '.
    WHERE PRODUCT = "FFF".

    I can't work on how I can join the other months on the line graph of a series.

    The error is as follows;

    --------------------------------------

    1 error has occurred
    Failed to parse the SQL query:
    Click link null, label, SUM (OCT_09) 'Non-communicable diseases - STD' of 'BI_A_DATA '. "" CDW_VS_NCDS_CALLS "WHERE PRODUCT ="MNT - STD' UNION ALL select link null, PRODUCT, SUM (NOV_09) "Non-communicable diseases - LOCAL" label of "BI_A_DATA". "" CDW_VS_NCDS_CALLS "WHERE PRODUCT ="MNT - LOCAL.

    ORA-00937: not a single group group function

    Some queries can be run when you run your application, if your query is syntactically correct, you can save your query without validation (see options below the source of the query).

    ----------------------------------------

    If anyone can help?

    I want a continuous linear graph showing monthly July 2008, Aug-08 Sep - 08 etc. to Jan - 10 for the same product.

    I will then add other series for other products, thanks

    OK a graphic line will only allow you to draw 1 variable (in this case period). Given that it is only for a single product, so here should be the final sql:

    SELECT null link, PERIOD label, SUM(ABC)
    FROM
    (SELECT 'JUL_08' PERIOD,SUM(JUL_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    
    UNION ALL
    
    SELECT 'AUG_08' PERIOD,SUM(AUG_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    
    UNION ALL
    
    SELECT 'SEP_08' PERIOD,SUM(SEP_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC')
    
    GROUP BY PERIOD
    
  • [ADF, JDev12.1.3] SelectOneChoiche created from VO instance with 3 fields: how to retrieve the value of all the fields of the selected element?

    Hallo,

    I defined a VO with 3 fields (A, B and C) and I would like to create a SelectOneChoiche that shows only the field as options from this instance of VO.

    In a managed bean, I need to retrieve the values for all areas (A, B and C) of the item selected by the user.

    I started dragging the entire VO instance to UI to create a SelectOneChoiche (in which I have chosen to show only the to field).

    Then, I created a for the SOC ValueChangeListener read the values A, B and C of the selected element, but the only thing I've done is to get the displayed value:

    System.out.println((String) ((RichSelectOneChoice) FacesUtils.findComponent("MySoc")).getValue());
    

    You kindly help me?

    Thank you

    Federico

    Federico, sorry I didn't see your answer.

    As you use 12.1.3 you can do this more easily than the code that I posted before. You can use

    {} public void onCountrySelection (ValueChangeEvent valueChangeEvent)

    FacesContext will involve = FacesContext.getCurrentInstance ();

    Make sure that the selection change is processed and the current link lov line has the new selected line

    valueChangeEvent.getComponent () .processUpdates (contxt);

    BindingContext lBindingContext = BindingContext.getCurrent ();

    BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry ();

    List JUCtrlListBinding = lBindingContainer.get ("CountryId") (JUCtrlListBinding);

    the newindex in not necessary, but ok let's get it (must be equal to the CountryId, the pharmacokinetics of the binding of the lov

    String newindex = (String) valueChangeEvent.getNewValue ();

    get the selected value in the list that is the selected line of the binding of the lov

    Line lFromList = list.getSelectedValue () (line);

    now, we can get the attributes of the line of lov

    String s = (String) lFromList.getAttribute ("CountryId");

    System.out.println ("CountryId:" + s);

    String s2 = (String) lFromList.getAttribute ("CountryName");

    System.out.println ("CountryName:" + s2);

    BigDecimal s3 = lFromList.getAttribute("RegionId") (BigDecimal);

    System.out.println ("RegionId:" + s3.toString ());

    }

    The form that I use is based on the location of the HR DB schema table. The CountryId is configured in the view object to display a lov based on the campagneVoir. This view contains thre CountryId, CountryName and RegionId attributes.

    If you want to get to the attributes of an action listener you can use this code

    {} public void onGetSelectedCountryLov (ActionEvent actionEvent)

    BindingContext lBindingContext = BindingContext.getCurrent ();

    BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry ();

    List JUCtrlListBinding = lBindingContainer.get ("CountryId") (JUCtrlListBinding);

    get the selected value in the list that is the selected line of the binding of the lov

    Line lFromList = list.getSelectedValue () (line);

    now, we can get the attributes of the line of lov

    String s = (String) lFromList.getAttribute ("CountryId");

    System.out.println ("CountryId:" + s);

    String s2 = (String) lFromList.getAttribute ("CountryName");

    System.out.println ("CountryName:" + s2);

    BigDecimal s3 = lFromList.getAttribute("RegionId") (BigDecimal);

    System.out.println ("RegionId:" + s3.toString ());

    }

    You must add the valueChangeListener and at least add the lines

    FacesContext will involve = FacesContext.getCurrentInstance ();

    Make sure that the selection change is processed and the current link lov line has the new selected line

    valueChangeEvent.getComponent () .processUpdates (contxt);

    to ensure that the selected line is available when you click the button.

    And set autosubmit'= true for the field in the UI that displays the LOV.

    Timo

  • Please help me with the Alternative of queries to replace the UNION ALL for two queries

    Hi all

    I have the query to retrieve assets employees salary count and in so far as below:

    Select ename, emp_no, sum (sal_till_2010), sum (sal_till_2014) of

    (select emp_no, ename, salary as sal_till_2010, 0 as sal_till_2014 of employee e1

    where effective_date < = 1 January 2010 ' and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = January 1, 2010 "")

    UNION ALL

    Select ename, emp_no, 0 as sal_till_2010, salary as employee e1 sal_till_2014 - here is a dummy 0 salary until 2010 for the union of all the

    where effective_date < = 1 January 2014 "and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = 1 January 2014") "

    Group of emp_no, ename;

    In this query, I get the total salary until 2010 and until 2014 in the employee table, dates are dynamically passed to the procedure, and this can change.

    But assume the date above and let me know the alternative of queries to improve performance because I use Union ALL and read the same table twice in the above query.

    Advice me with request to read the table once to fetch the same data as the above query.

    Thanks in advance.


    Hello

    Thanks for the display of the data of the sample; It's very useful!

    I think OP wants something like this:

    WITH cutoff_dates AS

    (

    SELECT TO_DATE (January 1, 2010 ', ' DD/MM/YYYY') AS cutoff_date, 2010 UNDER the label OF dual UNION ALL

    SELECT TO_DATE (1 January 2014 ', "DD/MM/YYYY"), double 2014

    )

    SELECT e.emp_no, e.ename

    , NVL (SUM (CASE WHEN c.label = 2010 THEN e.salary END), 0) AS sal_till_2010

    , NVL (SUM (CASE WHEN c.label = 2014 THEN e.salary END), 0) AS sal_till_2014

    E employee

    JOIN cutoff_dates c ON e.effective_date<=>

    WHERE DOES NOT EXIST)

    SELECT 1

    Of employee_deletion ed

    WHERE ed.emp_no = e.emp_no

    AND ed.deletion_date<=>

    )

    E.emp_no GROUP, e.ename

    ORDER BY e.emp_no

    ;

    Output of your sample data:

    EMP_NO ENAME SAL_TILL_2010 SAL_TILL_2014

    ---------- ------ ------------- -------------

    1 Mickey 450 0

    2 Donald 750 0

  • I created a PDF form with several drop downs, all with the same drop-down values. When I select a value of 1 in the drop-down list fields, it breeds in all others - which I don't want. How can I fix?

    I created a PDF form with several drop downs, all with the same drop-down values. When I select a value of 1 in the drop-down list fields, it breeds in all others - which I don't want. Can I fix?

    I am fairly new to this, but I think it has to do with the way you have drop them downs named. Copy you a then keep stick in each area? If so, that's the problem. You must rename each with a different number: Dropdown1, Dropdown2, etc. I think this might solve the problem.

  • Poblem with union/union all giving ORA-22950

    I use a select statement with the xmlelement to create an xml file.

    There the various unions end in 5, but I always bring a line through.

    I do like that as then I can use this as a cursor in my plsql without having to create lots of cursors when I only need to use a.
    That is to say.
    SELECT  xmlelement("QUOTATION",xmlagg(xmlelement(Quotation,
                          xmlelement(CUSTOMERNAME, customername),
                          xmlelement(QUOTE,quoteid )))xmlfile
    From cust, quote
    where custid=quotecustid
    and ptype = 'Q'
    UNION
    SELECT  xmlelement("SALES",xmlagg(xmlelement(SALES,
                          xmlelement(CUSTOMERNAME, customername),
                          xmlelement(QUOTE,salesid )))xmlfile
    From cust, sales
    where custid=salescustid
    and ptype = 'S'
    Then, I use a cursor to execute it in a ftp file folder I selected passing ptype as a parameter.

    If I use the union I get ORA-22950 - I have seen other people use UNION all around it.
    If I use union all I'll get a value for the SALE of any line that is

    Any ideas how I can get around this as do not want to continue to create cursors

    The use of different sliders is always the best approach IMO.
    All things considered, it should be more effective than that appearing more "smart" one.

    And there is no need to be explicit cursors, it could just be SELECT INTOs wrapped in a PL/SQL CASE statement, with the appropriate exception handler (if necessary).

    Anyway, if you want to stick with the single-cursor method, there are different ways to do this:

    (1) adding a column selector:

    SELECT xmlfile
    FROM (
      SELECT 'Q' as selector
           , xmlelement("QUOTATION",xmlagg(xmlelement(Quotation,
                      xmlelement(CUSTOMERNAME, customername),
                      xmlelement(QUOTE,quoteid )))xmlfile
      From cust, quote
      where custid=quotecustid
      and ptype = :1
      UNION ALL
      SELECT 'S'
           , xmlelement("SALES",xmlagg(xmlelement(SALES,
                      xmlelement(CUSTOMERNAME, customername),
                      xmlelement(QUOTE,salesid )))xmlfile
      From cust, sales
      where custid=salescustid
      and ptype = :1
    )
    WHERE selector = :1
    ;
    

    (2) adding a GROUP BY clause, so that XMLAgg returns nothing if no row is selected:

    SELECT xmlelement("QUOTATION",xmlagg(xmlelement(Quotation,
                    xmlelement(CUSTOMERNAME, customername),
                    xmlelement(QUOTE,quoteid )))xmlfile
    From cust, quote
    where custid=quotecustid
    and ptype = :1
    GROUP BY null
    UNION ALL
    SELECT xmlelement("SALES",xmlagg(xmlelement(SALES,
                    xmlelement(CUSTOMERNAME, customername),
                    xmlelement(QUOTE,salesid )))xmlfile
    From cust, sales
    where custid=salescustid
    and ptype = :1
    GROUP BY null
    ;
    

    (3) subqueries:

    SELECT case :1
            when 'Q' then ( SELECT ... )
            when 'S' then ( SELECT ... )
          end as xmlfile
    FROM dual
    ;
    
  • [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.)

  • with the clause with union all?

    Hello

    I tried to use 'by' article with union all. .but it gives me error...
       with t1 as 
            (select '1'col1 from dual union all
             select '2' col2 from dual)select * from t1
             union 
            with t2 as 
            (select '3' col1 from dual union all
             select '4' col1 from dual )
              select * from t2
                
    What harm am I doing here? Thank you very much!!

    Use the WITH clause, once for you all the subqueries, and then add the main request;

    with t1 as
     (select '1' col1
      from dual
      union all
      select '2' col2
      from dual),
    t2 as
     (select '3' col1
      from dual
      union all
      select '4' col1
      from dual)
    select *
    from t1
    union
    select *
    from t2;
    
  • Problem with Union All

    Hello Experts,

    I'm still on the learning curve in PL/SQL and I have 2 different. I need to create a view that will merge these 2 tables.
    create view eft_view as
    select 
      BILL_TO_RETAILER      ,
      RETAILER_NAME         ,
      NAME_ON_BANK_ACCOUNT  ,
      BANK_ABA              ,
      BANK_ACCT             ,
      ON_LINE_AMOUNT        ,
      INSTANT_AMOUNT        ,
      TOTAL_AMOUNT          ,
      SOURCE                ,
      INSERTED_DATE         ,
      CDC                   from weekly_eft_temp union all
    select 
      BILL_TO_RETAILER  ,
      RETAILER_NAME     ,
      STATUS            ,
      ON_LINE_AMOUNT    ,
      INSTANT_AMOUNT    ,
      NON_SWEPT_AMT     ,
      TTYPE             ,
      EXCEPTION_REASON   from weekly_bill_expt_temp;
    I used the union of all, but it doesn't seem to work. I don't know where it's track. I searched on the net but his send me examples for 2 tables tat are similar.

    Any suggestions please

    You must replicate the columns that do not exist fill them with NULL values.

    Perhaps;

    create view eft_view as
      select bill_to_retailer,
             retailer_name,
             name_on_bank_account,
             bank_aba,
             bank_acct,
             null status,
             on_line_amount,
             instant_amount,
             total_amount,
             source,
             inserted_date,
             cdc,
             cast (null as number) non_swept_amt,
             null ttype,
             null exception_reason
        from weekly_eft_temp
      union all
      select bill_to_retailer,
             retailer_name,
             null name_on_bank_account,
             null bank_aba,
             null bank_acct,
             status,
             on_line_amount,
             instant_amount,
             null total_amount,
             null source,
             null inserted_date,
             nul cdc,
             non_swept_amt,
             ttype,
             exception_reason
        from weekly_bill_expt_temp;
    
  • show all columns with union all

    Hi all
    select m_id, total, cat_id
    from scott.maintenance
    where prod_id = 1
    union all
    select m_id, total, prod_id
    from scott.maintenance
    where prod_id = 4
    How can I view all (and not common) columns of the two tables when I use union all like
    m_Id, total, cat_id, prod_id

    Thank you
    Johnny

    Hi, Johnny,.

    user9542267 wrote:
    Hi all

    select m_id, total, cat_id
    from scott.maintenance
    where prod_id = 1
    union all
    select m_id, total, prod_id
    from scott.maintenance
    where prod_id = 4
    

    How can I view all (and not common) columns of the two tables when I use union all like
    m_Id, total, cat_id, prod_id

    Thank you
    Johnny

    There is no need to make a trade UNION for this:

    SELECT  *
    FROM    scott.maintenance
    WHERE   prod_id IN (1, 4)
    ;
    

    If you really need to do a UNION and basic tables were the same or had the same number and types of columns, then you can use SELECT * in the two branches of the UNION:

    SELECT  *
    FROM    scott.maintenance
        --
    UNION ALL
        --
    SELECT  *
    FROM    foo.maintenance
    ;
    

    If the columns have different names in the two tables, the names of the first branch of the UNION will be used in the output.

    In all cases, you can add literal NULL values to the SELECT one or more branches of the UNION clause:

    SELECT  ename     AS name
    ,       hiredate
    ,       deptno
    FROM    scott.emp
        --
    UNION ALL
        --
    SELECT  dname     AS name        -- alias not necessary, but helpful
    ,       NULL      AS hiredate    -- alias not necessary, but helpful
    ,       deptno
    FROM    scott.dept
    ;
    

    Depending on your tables and your requirements of yor, you might be able to use SELECT * in a branch of the UNION.

    Published by: Frank Kulash, February 15, 2011 12:29

  • Adding columns with union all?

    --------------------------------------------------------------------------------------------------------
    SELECT BAGLANTIDATE, CABONE
    FROM SEDEF_BILGI
    WHERE CABONE = '1' AND
    BAGLANTIDATE BETWEEN TO_DATE('10-JUN-2009','DD,MON-YYYY')
    AND TO_DATE('11-JUN-2009','DD-MON-YYYY')
    
    UNION ALL
    
    SELECT KAYITDATE, ABONE
    FROM SEDEF_ISEMRI
    WHERE ABONE = '1' AND
    KAYITDATE BETWEEN TO_DATE('10-JUN-2009','DD,MON-YYYY')
    AND TO_DATE('11-JUN-2009','DD-MON-YYYY')
    ------------------------------------------------------------------------------------------------------------
    
    BAGLANTITARIH        ABONE
    ------------------------      ----------------
    10-JUN-09 03.01.52.546000000 AM 1          
    10-JUN-09 05.02.06.453000000 PM 1          
    10-JUN-09 01.01.20.421000000 PM 1          
    10-JUN-09 07.01.42.062000000 AM 1          
    10-JUN-09 09.44.59.515000000 AM 1          
    10-JUN-09 09.58.07.843000000 AM 1          
    10-JUN-09 09.01.50.546000000 PM 1    
    10-JUN-09 09.52.57.796000000 AM 1
    10-JUN-09 02.13.32.343000000 PM 1
    
    9 rows selected
    How can I add a column in the tables on that?

    Published by: niennamiriel on August 18, 2009 12:12 AM

    Yes it is possible.

    SELECT BAGLANTIDATE, CABONE, MSISDN
      FROM SEDEF_BILGI
      ...
    UNION ALL
    SELECT KAYITDATE, ABONE, null
      FROM SEDEF_ISEMRI
    
  • something faster than the UNION ALL?

    Hello

    I have two tables, with 20% and 80% of a total Group of data.
    The next time you press data, I need to have one top index so that the total dataset can be scanned.

    The result of this update is an update of the two tables.

    Here's my question (pls ignore syntax errors):

    I could do something like:

    create new_table
    As select * from t1
    UNION ALL
    Select * from t2

    change new_table add a primary key (acc_no)

    and then
    drop table t1
    drop table t2

    then the next cycle of treatment happens that, using new_table and a new set of entry, the t1 and t2 are filled (updates/inserts; and non-modifications/old)

    Then, new new_table is generated by t1 and t2... with a new index.

    This table is used again to read the next incoming batch of data, new filling t1 and t2...
    etc etc.

    actually, we have table t1 to send out of the database (flatfile). Then maybe we can do something faster as well. Maybe we don't need two tables at all?


    QUESTION 1:
    rather than generate a new table OF T2 T1 UNION ALL, I rather have the new table 'to be' the two tables? In this case, I just need to build the index on the table. Of course, t1 and t2 would disappear, but I have to drop them in any case for the next set of data.

    QUESTION 2:
    a little more advanced, is this table that combines all the results in the next 'as-is', must in fact be a table? I just need the appropriate fields (hm, in fact - all - fields) so I can make a new t1 and t2; There may be some smarter way to do it, without actually creating a new table t1 and t2 all the time...

    a big thank you in advance, your help is greatly appreciated

    Arne

    Rustydud wrote:
    Hi Dave Hemming.

    two thoughts on this approach,
    first of all I have not needed to keep the info on what were t1 and t2; they can be recessed. Rather the other way around, t1 + t2 will be "reborn" in the next run, based on the staging of new data and the "union all" table of the previous run (t1 + t2). then you see IS t1 + t2, after which t1/t2 would become useless.

    No, I do not say that you will not regenerate the tables t1 and t2. There is only one only true table new_table. Everything you would do the table t1 that you do view t1 and it is done as if by magic to the underlying new_table. Even with t2 - there is an opinion, not a table.

    The other approach is a view new_table which is a union of the tables t1 and t2, but then how do you index?

  • How to export the graph xy with indicator field.

    Hello

    I want to export my chart to the .emf format. For this I used call node > image export. If I use this, I can only export the chart not another indicator filed(numeric_and_string_indicatror).how can export chart with flag field?

    This is .vi I used.

    Thanks for your post in our Discussion Forum,

    is it necessary to export the image to the .emf Format?

    If not, I can give you two options:

    The best way to make a screenshot of a certain area of the façade is of

    create a Subvi with all the items you want to take a screenshot of and

    Then take a screenshot of the entire façade of the Subvi.

    It works fine even if the front is not visible, while the photo is taken.

    The screenshot can be taken with a method node as in the example attached to this post.

    Another possibility is to reframe a screenshot of an entire façade to the region you are interested in.

    How this works is described here: http://forums.ni.com/t5/LabVIEW/take-screenshot-of-part-of-front-panel/td-p/1613750

    The downside is that you must manually set the region that could change because of the scrolling or changes on the Panel.

    Best regards

    Peter

  • Ask. UNION ALL on two tables of dummy data

    I had a bit of SQL that joined a dynamic no cross table with another table of dummy data.

    WITH tbl_job_data AS (SELECT 'N' argument1, 'Y' argument2, NULL argument3, 'Y' argument4 FROM DUAL)
       , tbl_params   AS (SELECT 1 col_seq, 'From Project Number' col_prompt, NULL col_data, NULL col_attrib FROM DUAL UNION ALL
                          SELECT 2 col_seq, 'To Project Number'   col_prompt, NULL col_data, NULL col_attrib FROM DUAL UNION ALL
                          SELECT 3 col_seq, 'Through Date'        col_prompt, NULL col_data, NULL col_attrib FROM DUAL UNION ALL
                          SELECT 4 col_seq, 'Summarize Cost'      col_prompt, NULL col_data, NULL col_attrib FROM DUAL)
        SELECT  NULL AS col_seq
              , NULL AS col_prompt
              , d.col_data
              , d.col_attrib
        FROM    tbl_job_data
        UNPIVOT INCLUDE NULLS
                    (col_attrib
                FOR  col_data  IN (argument1
                                 , argument2
                                 , argument3
                                 , argument4)
                    ) d
        UNION ALL
        SELECT  tbl_params.col_seq
              , tbl_params.col_prompt
              , tbl_params.col_data
              , tbl_params.col_attrib
        FROM    tbl_params;
    
    
       COL_SEQ COL_PROMPT          COL_DATA  COL_ATTRIB
    ---------- ------------------- --------- ----------
                                   ARGUMENT1 N       
                                   ARGUMENT2 Y       
                                   ARGUMENT3         
                                   ARGUMENT4 Y       
             1 From Project Number                   
             2 To Project Number                     
             3 Through Date                          
             4 Summarize Cost                       
    
    8 rows selected.
    

    Sorry to be very naïve and ignorant, but is be possible that I can get the output in 4 lines like that, by a union on 2 statements:

       COL_SEQ COL_PROMPT          COL_DATA  COL_ATTRIB
    ---------- ------------------- --------- ----------
             1 From Project Number ARGUMENT1 N       
             2 To Project Number   ARGUMENT2 Y       
             3 Through Date        ARGUMENT3         
             4 Summarize Cost      ARGUMENT4 Y       
    

    I guess not, because the 2 tables don't really have a lot in common with them, but I thought I'd ask.

    Thank you

    Previously, contributed to these requests by Frank Kulash

    https://community.Oracle.com/thread/3810284 et https://community.Oracle.com/message/13361473

    WITH

    tbl_job_data AS

    (SELECT "n" argument1, argument2 'Y', NULL argument3, 'Y' argument4)

    OF THE DOUBLE

    ),

    tbl_params AS

    (SELECT 1 col_seq, number 'of the project"col_prompt, col_data, NULL, NULL col_attrib OF DOUBLE UNION ALL)

    SELECT 2 col_seq, col_prompt 'for the project number", NULL, col_data, NULL col_attrib OF DOUBLE UNION ALL

    SELECT 3 col_seq, col_prompt 'Date', NULL, col_data, NULL col_attrib OF DOUBLE UNION ALL

    SELECT 4 col_seq, col_prompt "summarizes the cost", NULL, col_data, NULL FROM DUAL col_attrib

    )

    Select y.*, x.*

    from (SELECT on col_seq (d.col_data control) row_number()

    NULL AS col_prompt

    d.col_data

    d.col_attrib

    OF tbl_job_data

    MUST INCLUDE NULL VALUES

    (col_attrib

    FOR col_data IN (argument1

    argument2

    argument3

    argument4)

    ) d

    ) x,.

    (SELECT tbl_params.col_seq

    tbl_params.col_prompt

    tbl_params.col_data

    tbl_params.col_attrib

    OF tbl_params

    ) y

    where x.col_seq = y.col_seq

    COL_SEQ COL_PROMPT COL_DATA COL_ATTRIB COL_SEQ COL_PROMPT COL_DATA COL_ATTRIB
    1 Project number - - 1 - ARGUMENT1 N
    2 For the project number - - 2 - ARGUMENT2 THERE
    3 By Date - - 3 - ARGUMENT3 -
    4 Summarize the cost - - 4 - ARGUMENT4 THERE

    Concerning

    Etbin

Maybe you are looking for

  • I downloaded Adobe filter but I don't know how to use it

    I asked for information on the web a blocker and was brought to Adobe filter. I downloaded it but there were no indications on how to use it for my children. Where can I learn to use it? I use the Windows XP operating system. I downloaded adobefilter

  • Windows reinstall failure on Satellite P35 - BSOD

    I had to reinstall windows XP on my Satellite P35. I deleted the partition - now, I think that it could have been a mistake. I get about half way through installing windows, then I get a blue error screen telling me that the installation could not be

  • How to merge two partitions, C and D

    Hello I HAVE A HARD DRIVE BUT ITS IN TWO SEPARATE PARTITIONS, ALL MY EXISTING FILES AND PROGRAMS ARE ON DRIVE C:\, DRIVE D:\ IS EMPTY. I WANT TO MERGE D:\ BY C:\ SO MY LAPTOP DISPLAYS ONLY A READER. HOW CAN I DO THIS WITHOUT LOSING ANYTHING ON C:\ DR

  • WSM Streaming Applications

    1. when streaming applications assigned to the device, instead of applications assigned to the user streaming be available? I waited for this feature since before the acquisition of Dell Wyse.

  • OptiPlex 360 drivers for Server 2003

    I have an Optiplex 360 that is running Windows Server 2003 and the video card was not all the drivers loaded for him. I think it's the installed Intel graphic card, 4 I see on this PC, but I have been unable to find a suitable driver for it. I tried