UNION & & OR

A funny experience:

the same meaning, but the result is different, because of the key word 'UNION' and 'GOLD '. What is the reason for this problem? Thank you!

SQL > SELECT count (PROD_ID)

2 FROM TABLE1

3. WHERE CHANNEL_ID = 3

4 or PROMO_ID = 350;

COUNT (PROD_ID)

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

547040

SQL > select count (PROD_ID))

2. SELECT PROD_ID FROM TABLE1

3. WHERE CHANNEL_ID = 3

4 UNION ALL

5. SELECT PROD_ID FROM TABLE1

6 WHERE PROMO_ID = 350).

COUNT (PROD_ID)

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

558350

The queries are not equivalent. UNION ALL is the concatenation of the results of two queries, including duplicates. Try the UNION and you'll see the difference.

--

John Watson

Oracle Certified Master s/n

Tags: Database

Similar Questions

  • I can't see a message from my Union because of problems with the address changed for pop-upwindows and some other issues

    Hello
    I am from Sweden and I have problems with a Web site that has my Union. I could see messages from them before, but they changed their address and on the site, they say people that they must put the new address on the approved list of the pop-up windows. I did but it still does not. Maybe I did wrong, I don't know, but it's annoying as hell that I can't see the messages they send.

    I really need help with that.

    Best regards
    Lena

    You can control and manage permissions for all areas on the Subject: authorizations page.

    You can delete all data stored in Firefox with a specific area through "Forget this Site" from the context menu of the history entry (see the history or the history sidebar) or via the subject: permissions page.

    Using "Forget this Site" will delete all data stored in Firefox in this area as bookmarks, cookies, words of past, cache, history, and exceptions, so be careful and if you have a password or other data from this area you don't want to lose so take note of these passwords and bookmarks.
    You can't recover from which "forget" unless you have a backup of the affected files.

    It has no lasting effect, so if come back you on such a 'forgotten' site, then the data of this Web site will be saved once more.

  • Search for edeposit at NFCU credit union

    I use Navy Federal Credit Union for banking online and I can't get my photosmart 6520 to search for an edeposit. I would appreciate any help with this problem

    Hello, can you give us a call at 888-868-8123 and one of our representatives can help you with your problem of eDeposit.

    Thank you

    Navy Federal Credit Union

  • How can I write a Dll to perform a union in visual studio for use in LabVIEW?

    Hello

    I am new to writing dll. I am trying to write a Dll that will perform a union on a number of LabVIEW and then return the result in LabVIEW for my use. I've been struggling with this during a few days and I finally give in to get help.

    This screenshot is the only description I have to help me with what I'm trying to do. Basically, I'm trying to pass a value that will be different according to a measurement of partial discharge. In the screen below, the value used is '1061111989' this number is my reading. I need to pass that value of labVIEW in my dll to perform a union on that.

    In my Dll, I need to write the value of MeterReading.IntVal and to the MeterReading.FloatVal.

    I have Visual Studio complete 2012 2012 Edition LabVIEW full, I'm LabVIEW CLAD and I wrote 17 floors of test to the United States to date. However, I've never needed Visual Studio so far. Can someone help me with this?

    Thanks in advance,-Chris

    Trying to create a Trade Union is stupid. Have you tried to make a simple conversion from type?

  • Typedef Union... failed

    Hello

    I've seen in a post that it is possible to create a union in LabVIEW [and without using a dll]

    but I do not understand the method, y at - there someone who can help me and explain how

    manage this trick in the following example:

    typedef struct _ssscmddata_haltest
    {
    U8 test_flags; Reserved, must be zero
    U8 test_start; SSSVAL_HAL_TSTART_xxxx
    U16 target_output; To the target in milli-amps or volts output
    U16 time_ramp_tgt; Target time in tenths of a second to the voltage ramp
    U16 time_hold; Target time in tenths of a second to maintain the tension
    U16 time_ramp_zero; Time in tenths of a second to the ramp to zero volts

    Union {}
    float r; Generic access
    float milli_amps; HIPOT. Used only at the end of the test for determining the pass/fail.
    float mega_ohms; DCIR. Used only at the end of the test for determining the pass/fail.
    float milli_ohms; BENJAMIN. Used only at the end of the test for determining the pass/fail.
    } lo_limit;

    Union {}
    float r; Generic access
    float milli_amps; HIPOT. Test fails immediately in case of exceeded this limit.
    float mega_ohms; DCIR. Used only at the end of the test for determining the pass/fail.
    float milli_ohms; BENJAMIN. Used only at the end of the test for determining the pass/fail.
    } hi_limit;

    U8 arc_detect; 0 to 9, 0 = disabled, 1 = most sensitive,..., 9 = least sensitive
    U8 channel; HAL: 0, HALSCAN: 0 to 4, G2, 0 = front, 1 back =
    } ssscmddata_haltest;

    [Thanks in advance:-]

    I may be a bit thick here, but what is the purpose of the union in your example?  I remember my days of line code that a Union is designed to manage several types of data into a memory block.  Your unions being all the floats, you could use simple float lo_limit/hi_limit and without the need to use a union.

    without searching the forum for trade unions, the closest direct structure of you, I can think of that would be an array of U8s, initialized to the specific number of bytes of your Union the most important "variable".   Then apply an overall style LV2 to prevent new memory allocation.  I'm not sure of is the efficiency of conversion in and out in the table.  Also, I don't know if you save a string with a number of characters if Labview not redirect memory anyway.

    Pei

  • Add value in a statement select union

    Hi have following sql,

    Select empname, 't' State, empno from tablename where column01 > 0

    Union of all the

    Select empname, 't' State, empno from tablename where column02 > 0

    Union of all the

    Select empname, condition of "W", empno FROM tablename WHERE COLUMN03 > 0

    Union of all the

    Select empname, condition of "Z", empno FROM tablename WHERE COLUMN04 > 0


    My use case is

    I have what it takes to add an additional column that is based on the slot status

    IN the column State

    If column01 > 0 to condtion 't' then quattiy 0

    If > 1 column02 of condition 'Y' then quatity is 1

    Condition IF COLUMN03 > 0 THAN 'w '.

    If COLUMN04 > 0 that the condition of "Z".

    If more than column 2 is < 0 to point out and it will be a quantity

    Select 't'

    TableName

    where column01 > 0

    Union of all the

    Select "y".

    TableName

    where column02 > 0

    Union of all the

    Select 'W '.

    TABLENAME

    WHERE COLUMN03 > 0

    I have what it takes to show value as it

    EmpName, condition, empno quatity

    Jerry, T, 1, 0158754585

    TOM, Y, 2, 0054789568

    Am in oracle database 11 g 2

    select empname, 'T' condition, empno,column01 + column02 + column03 + column04 quantity from tablename where column01 > 0
    
    union all
    
    select empname, 'T' condition, empno,column01 + column02 + column03 + column04 quantity from tablename where column02 > 0
    
    union all
    
    select empname, 'W' condition, empno,column01 + column02 + column03 + column04 quantity FROM tablename WHERE  COLUMN03 > 0
    
    union all
    
    select empname, 'Z' condition, empno,column01 + column02 + column03 + column04 quantity FROM tablename WHERE  COLUMN04 > 0
    
  • 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

  • How to filter records in a UNION ALL query

    Hi all

    I have only one requirement to filter records in a query UNION all. If we do not all matching records to one of the union, all question them.

    create table test_1(n1 number,n2 number,n3 number)
    
    insert into test_1 values(1,2,3);
    insert into test_1 values(11,22,33);
    insert into test_1 values(55,66,77);
    
    Case-1 :
    
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N2=2
    UNION ALL
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N3=3
    
    Output is : This is desired output(so we are good)
    
    1,2,3
    1,2,3
    
    Case 2 :
    
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N2=22
    UNION ALL
    SELECT N1,N2,N3
    FROM TEST_1
    WHERE N3=44
    
    Output : (Here is the problem: If we don't have matching records for anyone union all query we don't want any records)
    
    Output is coming : 11,22,33
    
    Out put : No Records (We want this output.)
    

    I hope I have given the clear example of my requirement.

    Thank you.

    with

    test_1 as

    (select 1 n1, n2 2, n3 3 of all the double union)

    Select 11,22,33 from all the double union

    Select double 55,66,77

    )

    Select the n1, n2, n3

    from (select n1, n2, n3

    of test_1

    where n2 =: n2

    Union of all the

    Select the n1, n2, n3

    of test_1

    where = n3: n3

    )

    where exists (select null from test_1 where n2 =: n2)

    and it exists (select null from test_1 where = n3: n3)

    Concerning

    Etbin

  • ODI 11 g multiple table with union join

    Hi all

    I have a problem with joining 4 different tables and union all of them.

    Here I want to generate this query;

    Select * from

    Table1, table2

    Join table2 = table1

    Union of all the

    Select * from

    Table 3, table 4

    Join table3 = table 4

    But I have not the same column that all the table, some are missing. When I write one - PL/SQL query I can easily add a false "NULL column1' column, but I can not how I do with ODI 11 g.

    I tried not to use "Active Mapping", but it does not work.

    I'm newbie ODI 11 g

    Thank you

    Myra

    Hi, Myra,.

    I'd even as in PL/SQL. In your table target add all the columns you need and overall data whatever you're missing some columns just put NULL in the mapping.

    Thank you

    Ajay

  • Need help with the use of GROUP BY in a select statement UNION

    I am writing a query that allows to combine a legacy system that interfaces it is trial balance in the Oracle of R12 GL.  It was only meant to continue for a month or two, but it is likely to continue for 6 months. Please Auditors Auditors, to provide proof that the system is in balance with Oracle GL.  By my verification requirements, I need to make a full reconciliation from the month of conversion (life in the amount of date), then PTD for each month. 

    The legacy account is placed in attribute1 on the lines of the journals. Uses of the old system balancing segments that are also used on the platform in Oracle for this division, i.e., Procure-to-Pay has been cut over Oracle, but not everything yet.  So, I can't count on the GL_BALANCES table for the info, I get from the JE_LINES.

    My problem is not the only request for the month.  But when I try to combine the queries with a Union, to aggregation of each measurement period in its own column, the group is necessary after each selected instruction rather than allowing me to put at the end of the UNION.  (When I put the group by at the end of the UNION, I have the 'not one group' function)

    So I get duplicate for each month of discrete measure accounts. When I duplicate in my Oracle database accounts, I can't count on the VLOOKUP function in excel to exactly match an account of inheritance.  I know there are more sophisticated ways to provide this output, but I'm hoping to get this info in a simple query.

    Thank you in advance for any advice you can provide

    Example of data output (the goal for me is to get the two rows to appear as one based on common points on the LEGACY_ACCOUNT and the ORACLE ACCOUNT

    The LEGACY ACCOUNT ORACLE ACCOUNT JUN_15 JUL_15 AUG_15 SEP_15 OCT_15 NOV_15 DEC_15
    010000001109000003584190-600552-1001-100231-000-0000-0000-000000-242961.040000
    010000001109000003584190-600552-1001-100231-000-0000-0000-00000192588.0200000

    Here is a simplified version of my code that returns both records.  In my research, I had found a number of conversations where it has been shown that the group could be put at the end of the select statement.  However, when I remove the group from the first select statement I get SQL error: ORA-00937: not a function of simple-group

    Select

    l.attribute1 LEGACY_ACCOUNT,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,

    JUN_15 TO_NUMBER('0').

    JUL_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),

    TO_NUMBER('0') AUG_15.

    TO_NUMBER('0') SEP_15.

    TO_NUMBER('0') OCT_15.

    TO_NUMBER('0') NOV_15.

    DEC_15 TO_NUMBER('0')

    Of

    b GL.gl_je_batches,

    GL.gl_je_headers h,

    GL.gl_je_lines l,

    GL.gl_code_combinations c,

    GL.gl_je_sources_tl j

    where b.je_batch_id = h.je_batch_id

    and h.je_header_id = l.je_header_id

    and l.code_combination_id = c.code_combination_id

    and h.je_source = j.je_source_name

    and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)

    ('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')

    and j.language = 'en '.

    and h.PERIOD_NAME ("JUL-15'")

    Group

    l.attribute1,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8

    UNION

    Select

    l.attribute1 LEGACY_ACCOUNT,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,

    JUN_15 TO_NUMBER('0').

    TO_NUMBER('0') JUL_15.

    AUG_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),

    TO_NUMBER('0') SEP_15.

    TO_NUMBER('0') OCT_15.

    TO_NUMBER('0') NOV_15.

    DEC_15 TO_NUMBER('0')

    Of

    b GL.gl_je_batches,

    GL.gl_je_headers h,

    GL.gl_je_lines l,

    GL.gl_code_combinations c,

    GL.gl_je_sources_tl j

    where b.je_batch_id = h.je_batch_id

    and h.je_header_id = l.je_header_id

    and l.code_combination_id = c.code_combination_id

    and h.je_source = j.je_source_name

    and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)

    ('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')

    and j.language = 'en '.

    and h.PERIOD_NAME ("AUG-15'")

    Group

    l.attribute1,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8

    order by 1

    Is there a good reason to make this period both as a series of trade unions?  This looks like a classic pivot for me query.  This will make a way through the tables and should get the desired results.

    Select l.attribute1 legacy_account,

    c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' | c.segment4: '-' |

    c.segment5: '-' | c.segment6: '-' | c.segment7: '-' | combination of c.segment8,

    sum (case when h.period_name = 'JUN-15'

    then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)

    otherwise 0 end) jun_15,.

    sum (case when h.period_name = 'JUL-15'

    then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)

    otherwise 0 end) jul_15,.

    - and similar to DEC - 15

    GL.gl_je_batches b, gl.gl_je_headers h, gl.gl_je_lines l.

    GL.gl_code_combinations c, gl.gl_je_sources_tl j

    where b.je_batch_id = h.je_batch_id

    and h.je_header_id = l.je_header_id

    and l.code_combination_id = c.code_combination_id

    and h.je_source = j.je_source_name

    and c.segment1 ('190', '191', '192', '193', '194', '195',' 196', ' 197',

    '198 ', '199', '200', '203', '205' ', 206',' 330 ', ' 331',

    "332 ', '333', '334', '335',' 336 ', ' 337')

    and j.language = 'en '.

    and h.period_name (' Jun-15', ' 15 JUL', ' AUG-15'... "" ")

    L.attribute1 group,

    c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' |

    c.segment4: '-' | c.segment5: '-' | c.segment6: '-' |

    c.segment7: '-' | c.segment8

    If you're on the 11G version of the database, you might want to look at the PIVOT keyword that will do the same thing in a more concise expression.

    John

  • Link to calendar for a calendar with a Union query

    I have a calendar with an SQL query. The query is a union with 3 different tables data.  When a user clicks the calendar of events, go to different pages based on the element in the query

    How to create the link.  Can someone guide me

    I'm on apex.oracle.com

    Caledar Query

    **************

    Select (event_no |) » -'|| event_name) name, event_date main_events

    Union of all the

    Select (order_no |) » -'|| order_name) name, Order_date main_orders

    Union of all the

    Select (action_number |) » -'|| wo_name) name, main_actions scheduled_start_date

    gkthomas wrote:

    Definition of color for the different elements are clear. But building the target of the dynamic link is not clear. Would you like to explain a little more.

    I also want the link to go to that particular record when the user click the input data for the calendar

    I don't really see how it can be made clearer. Have you read the online help for the attributes of link calendar? Do you understand the concept of chains of substitution? And the use of APEX URL to link pages and applications?

    Link target URL can be built dynamically in the region of link attributes. In a UNION data source, each request can contain values that are used to specify the different target pages and elements of page/values to define column. These columns are referenced in the attributes of calendar display/change link as substitution strings to specify the page number and set the values of the elements of the requested page:

    Source of the region


    select
        event_no || ' - ' || event_name event_title
      , event_date
      , 'apex-cal-green' css_class
      , '10' link_page
      , 'P10_EVENT_NO' link_items
      , event_no link_values
    from
        main_events
    union all
    select
        order_no || ' - ' || order_name
      , order_date
      , 'apex-cal-yellow' css_class
      , '11'
      , 'P11_ORDER_NO'
      , order_no
    from
        main_orders
    union all
    select
        action_number || ' - ' || wo_name
      , scheduled_start_date
      , 'apex-cal-red'
      , '12'
      , 'P12_ACTION_NO,P12_WO_NAME'
      , order_no || ',' || wo_name
    from
        main_actions
    

    View/Edit link

    f?p=&APP_ID.:&LINK_PAGE.:&SESSION.::&DEBUG.:&LINK_PAGE.:&LINK_ITEMS:&LINK_VALUES.
    


    If you really have trouble with this then as usual the best course of action is to create and share an example on apex.oracle.com where the proper techniques can be demonstrated.

  • mutiset separate union inside the collection

    
    DROP TYPE list_number;
    /
    
    DROP TYPE t_number;
    /
    
    CREATE OR REPLACE TYPE t_number IS OBJECT (a NUMBER);
    /
    
    CREATE OR REPLACE TYPE list_number IS TABLE OF t_number;
    /
    
    -- this code doesnt raise exception
    DECLARE
       w    list_number := list_number (t_number (1), t_number (2));
       w1   list_number := list_number (t_number (1), t_number (2));
       w2   list_number;
    BEGIN
       w2 := w MULTISET UNION  w2;
    END;
    /
    
    -- this code  raise exception when using distinct inside multiset with user defined collection
    --ORA-06550: line 6, column 10:
    --PLS-00306: wrong number or types of arguments in call to 'MULTISET_UNION_DISTINCT'
    DECLARE
       w    list_number := list_number (t_number (1), t_number (2));
       w1   list_number := list_number (t_number (1), t_number (2));
       w2   list_number;
    BEGIN
       w2 := w MULTISET UNION distinct w2;
    END;
    /
    
    -- this dosent raise exception when using distinct inside multiset 
    DECLARE
       TYPE list_num IS TABLE OF NUMBER;
    
       w    list_num := list_num (1, 2);
       w1   list_num := list_num (2, 2);
       w2   list_NUM;
    BEGIN
       w2 := w MULTISET UNION distinct  w2;
    END;
    /
    

    Hi gurus,

    When you use separate inside a collection of type multiset for schema-owned type exception is thrown for which I am unable to find the root cause

    Version

    11.2.0.3.0 Production NLSRTL

    Oracle Database 11g Enterprise Edition 11.2.0.3.0 64 bit Production

    PL/SQL 11.2.0.3.0 Production

    AMT for Linux: 11.2.0.3.0 Production

    SEPARATE means by comparing and throws exception since it does not know how to compare objects of type T_NUMBER. The map method, you must:

    SQL > CREATE OR REPLACE
    T_number TYPE 2
    3. IS ITEM)
    4 a certain NUMBER.
    5 FUNCTION of MEMBER card compare the RETURN NUMBER
    6              );
    7.

    Type of creation.

    SQL > CREATE OR REPLACE
    2 BODY of TYPE t_number
    3 EAST
    4 MEMBER card FUNCTION compare the RETURN NUMBER
    5 EAST
    6 BEGIN
    RETURN 7;
    8 END;
    9 END;
    10.

    Type the body created.

    SQL >
    SQL > CREATE or REPLACE TYPE list_number IS TABLE OF THE t_number;
    2.

    Type of creation.

    SQL > DECLARE
    2 w list_number: = list_number (t_number (1), t_number (2));
    3 w1 list_number: = list_number (t_number (1), t_number (2));
    W2 4 list_number;
    5 BEGIN
    6 w2: MULTISET UNION w2 w = separate;
    7 END;
    8.

    PL/SQL procedure successfully completed.

    SQL >

    SY.

  • Order by with Union

    select level as lvl --,1 as ordered 
    from dual
    connect by level <=5
    union all
    select rownum as lvl --,2 as ordered  
    from dual
    connect by level <=5 
    

    How to order the query after the UNION ALL clause in descending order

    My expected results

    1

    2

    3

    4

    5

    5

    4

    3

    2

    1

    Select * from (select level as lvl-, 1 as ordered

    of the double

    connect by level<>

    order by 1)

    Union of all the

    Select * from (select rownum as -lvl 2 as he ordered

    of the double

    connect by level<>

    order by 1 desc)

  • Just learned something new today - can include a column complete zero in a UNION statement

    I just thought it was pretty cool.

    SELECT null, job_id, NULL as manager_id, AVG (salary) as AVGSAL

    Employees

    GROUP BY department_id, job_id

    UNION ALL

    SELECT NULL, null, null, avg (salary) as AVGSAL

    OF hr.employees

    GROUP BY job_id, manager_id;

    I watched this and me "... sounds weird, how are the corresponding data types up."

    then I tried to run some scripts of myself and it works great. I guess that since the "datatype" NULL is not who collide with other data types, it makes sense.

    Huh? Why wouldn't you be able to include a null full column in a set of query results?

    Why do you think that it does not work?

    SELECT null, job_id, NULL as manager_id, AVG (salary) as AVGSAL

    Employees

    GROUP BY department_id, job_id

    UNION ALL

    SELECT NULL, null, null, avg (salary) as AVGSAL

    OF hr.employees

    GROUP BY job_id, manager_id;

    I watched this and me "... sounds weird, how are the corresponding data types up."

    then I tried to run some scripts of myself and it works great. I guess that since the "datatype" NULL is not who collide with other data types, it makes sense.

    No - there is NO SUCH THING as a NULL data type. A null is NOT a type of data: it represents an UNKNOWN value and does NOT have a data type.

    Because NULL is not a dataype is NOT in conflict with ANY data type of a column to a different query.

    See the sections of Oracle doc on NULL values

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/sql_elements005.htm

    You can convert a NULL value to a data type specific well and then because you have a conflict of data type, you will get an exception:

    SELECT cast (null as varchar2 (10)), job_id, cast (NULL as number (10)) as manager_id,.

    AVG (salary) as AVGSAL FROM employees

    GROUP BY department_id, job_id

    UNION ALL

    SELECT cast (NULL as number (10)), null, cast (null as varchar2 (10)).

    AVG (salary) as hr.employees AVGSAL

    GROUP BY job_id, manager_id;

    ORA-01790: expression must have same type of data, matching expression

    This exception is due to the incompatibility of data type of explicit CASTs.

    See the CAST operator in the Oracle documentation

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/functions016.htm

    CASTConverts a type of built-in data or value typed collection to another type of built-in data or value-typed collection.

  • Why UNION ALL allows no column names only when a literal is used and there is at least 3 parts of the query?

    An artificial union all:

    SQL> SELECT Dummy FROM Dual ORDER BY Dummy;
    
    D
    -
    X
    
    SQL> SELECT Dummy FROM Dual UNION ALL SELECT Dummy FROM Dual ORDER BY Dummy;
    
    D
    -
    X
    X
    
    SQL> SELECT Dummy FROM Dual UNION ALL SELECT Dummy FROM Dual UNION ALL SELECT Dummy FROM Dual ORDER BY Dummy;
    
    D
    -
    X
    X
    X
    
    
    

    It literally changes it:

    SQL> SELECT NULL A FROM Dual ORDER BY A;
    
    A
    -
    
    
    SQL> SELECT NULL A FROM Dual UNION ALL SELECT NULL FROM Dual ORDER BY A;
    
    A
    -
    
    
    
    SQL> SELECT NULL A FROM Dual UNION ALL SELECT NULL FROM Dual UNION ALL SELECT NULL FROM Dual ORDER BY A;
    SELECT NULL A FROM Dual UNION ALL SELECT NULL FROM Dual UNION ALL SELECT NULL FROM Dual ORDER BY A
                                                                                                     *
    ERROR at line 1:
    ORA-00904: "A": invalid identifier
    
    
    SQL> SELECT NULL A FROM Dual UNION ALL SELECT NULL FROM Dual UNION ALL SELECT NULL FROM Dual ORDER BY 1;
    
    A
    -
    
    
    
    
    

    Why 3 is the magic number?

    My friend, this is what I would call a "bug".

    However, my opinion doesn't matter, because I do not work for Oracle

    You opened a SR with Oracle?

  • the Union and the order of etl_run_num_seq

    Hello

    Using oracle 11.2.0.3 and have fowlling sql

    Select cola, colb

    table one

    where...

    order of teachers

    Add a union in this

    for example

    Select cola, colb

    table one

    where...

    order of teachers

    Union

    Select cola, colb

    of table b

    where...

    order of teachers

    get the message ORA-00933 not correctly completed sql command

    Works if do

    (select cola, colb)

    table one

    where...

    Union

    Select cola, colb

    of table b

    where...

    )

    order of teachers

    East - the best and only way to do it?

    Use the COMMAND BY only once and use the number of the column...

    Select cola, colb

    table one

    where...

    Union

    Select cola, colb

    of table b

    where...

    order by 1

Maybe you are looking for

  • I can't change the location of the iTunes library

    I used iTunes with my Mac Mini, and all the music and video have been stored in the main hard drive. As I added a 120 GB SSD inside the Mini and installed OS X (El Capitan) in it, I want to change the default location my iTunes library in the folder

  • HP 110-023W: I need boot disk installation instructions for my desktop PC.

    I replaced my hard drive and I am looking for the instructions of installation for my boot disks I just ordered, but don't see anything on the forum for my desktop HP 110-023W.   My original OS was Windows 8, but upgraded to Windows 10.

  • examples of LabVIEW ARM code

    Hello I am new to Labview ARM I used an ek-lm3s8962 Keil Committee. I would like to know if there are a few tutorials and code examples on communications with devices: How to write you SD card? How to use CAN, SPI, I2C and UART? How to use the OLED?

  • HP Officejet Pro 6830 e: head printer problem

    I just started having problems of printer head.  Used doctor Scan, plugged and unplugged the printer, the computer restarted and all the steps that they have you spend and still, it gives printer error reading head.  Someone had a bit of luck with cl

  • Laptop was dropped, now my CD player is not recognized

    I dropped my laptop for a long time and about a week later, I tried to burn a CD and I realized that my cd drive is not recognized by my laptop. The Player opens and closes smoothly, but it is not just recognized. When I go to 'my computer' the drive