management of NULL values in a statement PIVOT 11 g

Hi all

In the following code, how can I get the cell showing 80001_sum_sales for employee 234567 as a zero instead of a NULL value?
with t1 as 
(
 select 123456 as emp_id, 80000 as category, 10 as sales from dual union all 
 select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
 select 234567 as emp_id, 80000 as category, 10 as sales from dual 
)
select *
  from t1 pivot ( sum(nvl(sales,0)) as sum_sales for category in (80000, 80001));
I tried NVL in various parts of the application, but the problem is that the line does not actually exist to apply the NVL to. I also tried to add another level of subquery factoring to wrap each column in an NVL, something like:
with t1 as 
(
 select 123456 as emp_id, 80000 as category, 10 as sales from dual union all 
 select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
 select 234567 as emp_id, 80000 as category, 10 as sales from dual 
), 
 t2 as (select *
        from t1 pivot ( sum(sales) as sum_sales for category in (80000, 80001)) )
select emp_id,
       nvl(80000_sum_sales, 0) as "80000"
       nvl(80001_sum_sales, 0) as "80001"
       from t2;
but Oracle has a problem with the fact that the column name starts with a number and get ORA-00911. Something like:
with t1 as 
(
 select 123456 as emp_id, 80000 as category, 10 as sales from dual union all 
 select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
 select 234567 as emp_id, 80000 as category, 10 as sales from dual 
), 
 t2 as (select *
        from t1 pivot ( sum(sales)  for category in (80000, 80001)) )
select emp_id,
       nvl(80000, 0) as "80000",
       nvl(80001, 0) as "80001"
       from t2;
shows just the values 80000 and 80001 rather than actual sales amounts. Unfortunately, my requirement is that these column headers must be digital, as is an interface in another system. I try to avoid a full outer join a list of categories to all employees, as my employee table has 180 m files in there.

Are there SQL gurus out there who can see a way around this problem, before I attempt an outer join complete?

Thank you
Matt

Hello

Try this

with t1 as
(
 select 123456 as emp_id, 80000 as category, 10 as sales from dual union all
 select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
 select 234567 as emp_id, 80000 as category, 10 as sales from dual
),
 t2 as (select *
        from t1 pivot ( sum(sales)  for category in (80000, 80001)) )
select emp_id,
       nvl("80000", 0) as "80000",
       nvl("80001", 0) as "80001"
       from t2;

see you soon

VT

Tags: Database

Similar Questions

  • Replace NULL values with 0 to Pivot

    Hi all

    I use a union query, I need to display 0 instead of NULL values. I tried various methods such as ifnull(), case; I could see in the table, but not in pivot of 0.
    I tried and succeeded in placing '-' instead of null. If I put a line chart the chart seems meaningless.
    Can someone suggest me this chart & pivot.

    Thanks in advance,
    Jerome

    Hi Leila,

    Hope this link helps you

    [http://total-bi.com/2010/10/replace-nulls-in-obiee-pivot-table/]

    By,.
    KK

  • Replace NULL values for PIVOT query

    Hello

    I'm working a table for sales, for certain values, when now columns, finishing with a null value. How can I handle these values 0 (zeros).

    WITH (AS PIVOT_DATA)
    SELECT S.ZONE_CODE, Z.ZONE_NAME, S.YEAR, S.PERIOD, S.SALES
    OF STAT_TABLE_SALES ADV
    AREAS OF JOIN Z ON S.COMP = Z.COMP AND S.ZONE_CODE = Z.ZONE_CODE
    WHERE S.COMP = '001'
    AND S.BRAND_CODE = '001'
    )
    SELECT *.
    OF PIVOT_DATA
    PIVOT)
    SUM (SALES) FOR THE PERIOD (YEAR) TO ((20091),
    (2009,2),
    (2009,3),
    (20094)
    (2009,5),
    (2009,6),
    (2009,7),
    (2009.8),
    (2009,9),
    (2009.10)
    (2009,11),
    (2009.12),
    (2010,1),
    (20102)
    (2010,3),
    (2010,4),
    (2010,5),
    (2010,6),
    (2010.7))
    )
    ORDER BY DESC NULLS LAST 14;

    This query returns the following:

    COD_ZONA NOM_ZONA 2009_3 2009_2 2009_1
    -------- ------------------------------ ---------------------- ---------------------- --------------------
    01 YEDUSIJH. 1382367.75 1559943.27 1441279.64
    02 C, ASKAK 711897.82 865854,05 1583232.3
    ASDFG 03 130443.03 205409,84 178633.69
    04 OSOIDSD 320118.32 439008,83 409251.18
    05 ODFSDF 300908.21 276301,59 260188.53
    06 CH 242749.65 325196,71 464938.9
    SOA 07 610312.31 606312,93 754569.82
    08 SAN 89426.8 81360,04 61649.27
    09 YP 284487.79 328281,31 267210.85
    10 TC 87043.28 158594,43 85195.8
    11 BAGNN 76778.78 68180,76 118530.04
    12 CRT 122023.7 143442,21 134744.85
    13 ABC 209992.79 196477,03 185222.14
    IDLIB 14
    15 ARE 23870.41 4137,33 16660.53

    * These are not all the columns and rows, but it is a piece of what it returns.

    How can I replace the NULL values with 0 (zeros).

    Still not sure why nvl shouldn't meet your needs:

    SQL> select ename, nvl (clerk_20, 0) clerk_20, nvl (sal_30, 0) sal_30
      from emp pivot (sum (sal)
               for (job, deptno)
               in ( ('CLERK', 20) clerk_20, ('SALESMAN', 30) sal_30))
    /
    ENAME             CLERK_20          SAL_30
    ---------- --------------- ---------------
    WARD                     0            1250
    JONES                    0               0
    TURNER                   0            1500
    ADAMS                 1100               0
    ALLEN                    0            1600
    SMITH                  800               0
    CLARK                    0               0
    KING                     0               0
    BLAKE                    0               0
    JAMES                    0               0
    FORD                     0               0
    SCOTT                    0               0
    MARTIN                   0            1250
    MILLER                   0               0
    
    14 rows selected.
    
  • NULL values in service management LESS

    Hello

    I have the query unless you return through two date fields date... NULL values should be ignored in the calculation. I used the service LESS with NVL but not able to resolve the issue until I used the function REPLACE top of it to show the value NULL if the query returns date of NVL. Please find the tables and queries that I used...
    CREATE TABLE TEST_LEAST
    (RECORD NUMBER,
    DATE1 DATE,
    DATE2 DATE,
    DATE3 DATE);
    INSERT INTO TEST_LEAST VALUES (1, '1 AUG 2009', '23 JUN 2009', '4 APR 2009');
    INSERT INTO TEST_LEAST VALUES (2, '20 JAN 2009', '16 FEB 2009', '7 MAY 2009');
    INSERT INTO TEST_LEAST VALUES (3, NULL, '31 MAR 2009', '19 JUL 2009');
    INSERT INTO TEST_LEAST VALUES (4, NULL, NULL, NULL);
    COMMIT;
    To return date less date1 and date2, date3, I used the function LESS, but the result was not as expected with the following query:
    SELECT RECORD, LEAST(DATE1, DATE2, DATE3) FROM TEST_LEAST;
    Statement 3 should show a date of March 31, 2009.

    I changed the query to use NVL to handle NULL values...
    SELECT CASENBR, LEAST(NVL(DATE1, TO_DATE('31 DEC 9999')), NVL(DATE2, TO_DATE('31 DEC 9999')), NVL(DATE3, TO_DATE('31 DEC 9999'))) FROM TEST_LEAST;
    .. but now, the result shows that record 4 is December 31, 2009, instead of NULL.
    and finally, I replaced the date 31 DEC 2009' with null with this query...
    SELECT CASENBR, REPLACE(LEAST(NVL(DATE1, TO_DATE('31 DEC 9999')), NVL(DATE2, TO_DATE('31 DEC 9999')), NVL(DATE3, TO_DATE('31 DEC 9999'))), TO_DATE('31 DEC 9999'), NULL) FROM TEST_LEAST;
    I am not convinced with query then thought to ask THE GURUS for help. Please guide me how I can better handle nulls with LESS function.

    Thanks in advance!

    Use COALESCE with the first expression that column:

    SQL> SELECT RECORD, LEAST(COALESCE(DATE1,DATE2,DATE3),COALESCE(DATE2,DATE3,DATE1),COALESCE(DATE3,DATE1,DATE2))FROM TEST_LEAST;
    
        RECORD LEAST(COA
    ---------- ---------
             1 04-APR-09
             2 20-JAN-09
             3 31-MAR-09
             4
    
    SQL> 
    

    SY.

  • Alter the State of Session? -Apex form publishes text with null value

    Recently I discovered a problem with our Apex facility in which all selected as source for a text field value will eventually be displayed as a null value in the database.
    We run APEX version 3.2 in an Oracle 10.2.0.4 database using Oracle HTTP Server from 10 g companion disc.

    At first glance, everything seems to work as expected; I created a simple table called "oracle_sr" with 2 columns, as both not null:

    SQL > desc capacity.oracle_sr
    Name Null? Type
    ORACLE_SR_ID NOT NULL NUMBER
    TIMESTAMP NOT NULL DATE

    In APEX, the form wizard has been used to create a form on this table.
    After execution of the pages and you enter a value for the timestamp field, I can create folders without problem.

    The question arises when I choose a source for the timestamp field value.
    All the source options causes the same error (including a static value) so I'll focus on the SQL query to the source as:

    Select sysdate double;

    This should replace the date system in the area of text timestamp when the page is executed.
    As expected, the value appears in the text box, but when I submit the form to create the folder I get the error:

    ORA-01400: cannot insert NULL into ('ABILITY'. "" "" ORACLE_SR '. "" TIMESTAMP")

    I have worked with APEX for quite awhile and have successfully used this technique in many applications but just to begin to see this error in recent days. What's particularly odd about this message is by default postings "not null" created by the form wizard sees timestamp class as having a value. Session state information included below reports a value yet the database is to launch the ORA-01400.

    Someone has a similar problem? I have spent a good amount of time to try looking for this problem but can't seem to find any similar messages.

    I have included the release of my test page, debugging from what I see, it seems to be a value associated with the filed timestamp:

    0.00: a C C E P t: request = "CRΘER."
    0.00: metadata: go look up the definition and application shortcuts
    0.00: NLS: wwv_flow.g_flow_language_derived_from = FLOW_PRIMARY_LANGUAGE: wwv_flow.g_browser_language = en - us
    0.00: alter session set nls_language = "AMERICAN."
    0.00: alter session set nls_territory = 'AMERICA '.
    0.00: NLS: CSV charset = WE8MSWIN1252
    0.00:... "NLS: decimal separator Set =". »
    0.00:... NLS: Set NLS Group separator = ",".
    0.00:... NLS: Date Format Set = "DD-MON-RR.
    0.01:... Setting session time_zone in-06: 00
    0.01: setting NLS_DATE_FORMAT application date format: DD-MON-RR
    0.01:... NLS: Date Format Set = "DD-MON-RR.
    0.01: fetch database session state
    0.01:... Check the owner of the 2303701116904676 session
    0.01: setting NLS_DATE_FORMAT application date format: DD-MON-RR
    0.02:... NLS: Date Format Set = "DD-MON-RR.
    0.02:... Check for expiration of the session:
    0.02:... Metadata: Page Fetch, calculation, process and branch
    0.02: session: extract information from session header
    0.02:... Metadata: Retrieve the attributes of the page for application 109, page 50
    0.02:... Validate page affinity point.
    0.02:... Check off the items hidden_protected.
    0.03:... Check authorization security systems
    0.03: session state: Save elements of form and p_arg_values
    0.03: *... Session state: you save newValue of the object "P50_ORACLE_SR_ID" = "" "escape_on_input ="N"* 0.03: *..." " Session state: you save the object "P50_TIMESTAMP" = newValue ' 26 May 09 "" escape_on_input = "N" * ""»
    0.03:... Session state: Save "P0_CURRENT_PERSONNEL_ID" - registration of same value: "1."
    0.03:... Session state: Save "P0_OFFSET" - registration of same value: "0".
    0.03:... Session state: Save "P0_ACTIVE_WEEK" - registration of same value: "24 May 09".
    0.03: point of treatment: ON_SUBMIT_BEFORE_COMPUTATION
    0.03: branch point: BEFORE_COMPUTATION
    0.03: point of calculation: AFTER_SUBMIT
    0.03: tabs: make the connection for the tab queries
    0.03: branch point: BEFORE_VALIDATION
    0.03: perform validations:
    0.03:... Point Not Null Validation: P50_TIMESTAMP
    0.04: branch point: BEFORE_PROCESSING
    0.04: point of treatment: AFTER_SUBMIT
    0.04:... Process 'PK get': PLSQL (AFTER_SUBMIT) declare function get_pk return varchar2 is begin C1 in (select ORACLE_SR_SEQ.nextval double next_val) loop return c1.next_val; end loop; end; Start: P50_ORACLE_SR_ID: = get_pk; end;
    0.04:... * session state: saved point new value "P50_ORACLE_SR_ID" = "6."
    0.04:... Treat "Line of ORACLE_SR process": DML_PROCESS_ROW (AFTER_SUBMIT) #OWNER #:ORACLE_SR:P50_ORACLE_SR_ID:ORACLE_SR_ID | IUD
    0.04: see the error page...
    0.04: execute rollback...

    ORA-01400: cannot insert NULL into ('ABILITY'. "" "" ORACLE_SR '. "" TIMESTAMP")

    Cannot process the row in the ORACLE_SR table.
    Back by demand.

    Any thoughts would be appreciated.

    Thank you

    Justin.

    If you have changed the Source Type of an element of database column to something else, so he cannot participate in the automated line choreography Fetch/automatic line processing (DML). You must leave the Type of Source, as it was and change the default value of the element fill when the ARF process retrieves a null value for the column.

    Scott

  • LOV displayed as null when it has a value in session state

    I use ajax to Dene Kubinek cascading select list example and it works fine. I have only one small problem. After the process of database update is running, and the page is refreshed the second selection list of with the null value when it has a value of 6 session state. Even if the database is updated with the correct value users will think that a null value has been updated because it shows - select Team - rather than the team that was selected.

    How can I fix it? I have read dozens of threads on the forum about the cascading selection lists and none of them seem to address this issue. I followed messageID = 2803572. When I changed the first select list of a select list with submit it wouldn't work because the onchange process did not run.

    It's very frustrating because the first select list contains the correct value in session state, and it is to show the selected value. I only have this problem with the second select list. I don't have two selection lists, one meets the other.

    Here is the code for my second selection list:

    SELECT TEAM_DESC, TEAM_ID
    OF CEAH_TEAMS
    WHERE UNIT_ID = NV(:P116_CENTER) or NV(:P116_CENTER) = - 1

    I use the same code in another form and it works very well. The only difference is that the other form already has a value for the first list in the selection, so I didn't need additional code to check the value zero. If I don't check the null value (: P116_CENTER = - 1) I get a LOV error when the page initially loads.

    Help. Thanks in advance, Elizabeth

    Salvatore - brilliant! Of course.

    Scott

  • How to manage a transitional calculated attribute in my vo than sometimes groovy expression of null values?

    Mr President

    My worm jdev is 12.2.1

    In my transient VO sometimes attribute I have null values in the expression groovy

    (Purqty*Unitpurprice)+ (Purqty*Unitpurprice)*Staxrate/100
    

    Some products have sales tax rates, and some have Staxrate NULL.

    And I get the following error because of this.

    NULL ERRORS.png

    My question is that how to avoid this error.

    Concerning

    You can do a null control in your expression.

    If (Staxrate! = null & Salestax! = null) {}

    Return ((Purqty*Unitpurprice) + (Purqty * Unitpurprice) * Staxrate/100)

    }

    else {}

    Returns 0

    }

  • FTS by select as NOT NULL values

    Hello

    My version of Oracle is 10.2.0.3.0.

    I'm shot under SQL in the database, this SQL is a FTS during the race.

    SELECT *.
    Table_name FROM
    WHERE id_number IS NULL;

    Pease see below for the nature of the existing data in the table.

    SQL > select count (*) from table_name where id_number is null;

    COUNT (*)
    ----------------
    1456

    SQL > select count (*) from table_name;

    COUNT (*)
    ----------------
    9392730

    However, there is an index on the column id_number and the SQL where clause (where id_number is null) picks up only 0.1% of the rows in the table. Although SQL is a FTS on the table table_name. Is there a way I can remove this execute SQL FTS.

    Thanks in advance.

    Best regards
    oratest

    oratest wrote:
    Means there is no another way/workaround to grant this SQL? :(

    Major responses in this thread.

    If you change the SQL statement or set up a bitmap index (not a good choice index if the table is subject to frequent changes), there is another solution. I think I've seen this approach on the blog of Richard Foote:
    http://richardfoote.WordPress.com/2008/01/23/indexing-nulls-empty-spaces/

    Here's a sample:

    CREATE TABLE T1(
      C1 NUMBER NOT NULL,
      C2 VARCHAR2(50) NOT NULL,
      C3 NUMBER,
      C4 VARCHAR2(300));
    
    INSERT INTO T1
    SELECT
      ROWNUM,
      TO_CHAR(ROWNUM,'0000000')||'A',
      DECODE(MOD(ROWNUM,1000),0,NULL,ROWNUM),
      LPAD('A',300,'A')
    FROM
      (SELECT
        ROWNUM RN
      FROM
        DUAL
      CONNECT BY
        LEVEL <= 1000) V1,
      (SELECT
        ROWNUM RN
      FROM
        DUAL
      CONNECT BY
        LEVEL <= 1000) V2;
    
    CREATE INDEX IND_T1_C3 ON T1(C3);
    
    EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T1',CASCADE=>TRUE)
    

    The foregoing has created a ranking table 1 000 000, where 1 of 1,000 rows contains a NULL value. An index has been created and then on the table, and the statistics have been updated.

    Now the first test:

    SET AUTOTRACE TRACEONLY EXPLAIN
    
    SELECT
      COUNT(*)
    FROM
      T1
    WHERE
      C3 IS NULL;
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3724264953
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     1 |     5 | 10994   (2)| 00:00:45 |
    |   1 |  SORT AGGREGATE    |      |     1 |     5 |            |          |
    |*  2 |   TABLE ACCESS FULL| T1   |  2000 | 10000 | 10994   (2)| 00:00:45 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       2 - filter("C3" IS NULL)
    

    Note that the index is not used. A second test with a slightly modified definition of the index:

    CREATE INDEX IND_T1_C3_NULL ON T1(C3,' ');
    
    EXEC DBMS_STATS.GATHER_INDEX_STATS(OWNNAME=>USER,INDNAME=>'IND_T1_C3_NULL')
    
    SELECT
      COUNT(*)
    FROM
      T1
    WHERE
      C3 IS NULL;
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 265035506
    
    ------------------------------------------------------------------------------------
    | Id  | Operation         | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |                |     1 |     5 |    25   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |                |     1 |     5 |            |          |
    |*  2 |   INDEX RANGE SCAN| IND_T1_C3_NULL |  2000 | 10000 |    25   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       2 - access("C3" IS NULL)
    

    This time notice that the special index was used without having to change the SQL statement.

    Charles Hooper
    Co-author of "Expert Oracle practices: Oracle Database Administration of the Oak Table.
    http://hoopercharles.WordPress.com/
    IT Manager/Oracle DBA
    K & M-making Machine, Inc.

  • The Manager is null in PopupScreen

    Ignore this thread, I just made a stupid mistake in my own code and it had nothing to do with PopupScreen.

    Hi all

    I have the following problem, and I can't believe my eyes... I get off PopupScreen, I pass a new handler instance to the constructor inherited super caller and then on the line following getManager() returns null. (And of course add calls fail). For example:

    public class that dialogue extends PopupScreen implements {FieldChangeListener}

    [....]

    Public dialogue (properties conf, string text [, String String Yes, no, listening to the listener) {}
    Super (new VerticalFieldManager());

    log.log ("Manager ="+ getManager()); say the Manager is null
    This.Listener = listener;
            
    for (int i = 0; i)< text.length;="" i++="" )="">
    Add (new LabelField (text [i], Field.FIELD_HCENTER)); Throws NPE, while the text and the text [i] is NOT null. Without a doubt.
    }

    Has anyone seen anything like this before? I checked some of my first projects and (unsurprisingly), I could do the same thing without guile ay. (In fact it is wrong one could do here, since calling the inherited constructor must be the first statement...) Now, this fails for me on 4.2.1 4.5.0 and 4.7.0.

    At first, I thought that's a few threads question undocumented (I was bringing together the UI in a GUI thread not before calling enterEventDispatcher), but that works in all of my projects and I changed the boot in the end sequence, so who know it happens after the call to enterEventDispatcher. I tried to move it to the thread of the event, but it still does not work as a result. (As I look at the code it shouldn't be there all multithreaded processing issues.) At least as long as it's a java virtrual machine and not only something similar.)

    Laszlo

    ... and how to get away from the problem, sleep and talk (post on the forum) help to solve... I have accidentally overridden method add to be able to add components from the outside to a specific part of the window (just like with the standard dialog box class). Which was to throw the exception when it is called from the constructor as the manager used in there would be initialized later. Sorry, my bad, thanks for your efforts .

  • Null value? What the h is a Null value in my registry events?

    while I'm compensation of errors I have 1 last error, apparently harmless but annoying nonetheless, I want to get all these events "Null" out of my system.

    Log name: System
    Source: Service Control Manager
    Date: 23/02/2013-11:54:52
    Event ID: 7026
    Task category: no
    Level: error
    Keywords: Classic
    User: n/a
    Computer: INTL
    Description:
    The next (s) starting or starting system could not load:
    Null value
    The event XML:
    http://schemas.Microsoft.com/win/2004/08/events/event">
     
       
        7026
        0
        2
        0
        0
        0 x 8080000000000000
       
        9113
       
       
        System
        INTL
       
     

     
       
    Null value

     

    your help is appreciated, thanks

    Al Adams

    Hello

    Thanks for the reply.

    Your question does contain all the required information necessary for us to help you. Please provide us with more information to continue troubleshooting as a result.

    See the link on how to ask questions or help on the Forums.

    Suggestions for a question on help forums: http://support.microsoft.com/kb/555375

    Thank you.

  • Remove data with null value

    Hello

    I'm using Oracle 11 g. I have a table with an id of 3, node, the value column. Combination of the column id and node, that must be taken account for deletion on the registers.

    Here, I need to delete lines with the NULL value in the value column. If for a combination of id and node with non-null values, then I need to delete rows with a null value for this combination.

    If the combination of id, node is not null value then this records should not delete.

    Below table, I need to remove the second row, for which is a value not zero VOICE CAL '10' is there, so I need to delete the row with null values. (VOICE, CAL, NULL)

    Network, FL, there is no value is non-null then I should NOT delete this line.

    This table is to have 100 s of this association, we can delete data in a single delete query?

    Or how I can delete rows with nulls for this combination.

    Tab1

    VALUE OF THE NŒUD ID

    VOICE CAL 10
    VOICE CAL NULL
    NETWORK NULL FL

    Thank you

    Hello

    oradba11 wrote:

    Hello

    I'm using Oracle 11 g. I have a table with an id of 3, node, the value column. Combination of the column id and node, that must be taken account for deletion on the registers.

    Here, I need to delete lines with the NULL value in the value column. If for a combination of id and node with non-null values, then I need to delete rows with a null value for this combination.

    If the combination of id, node is not null value then this records should not delete.

    Below table, I need to remove the second row, for which is a value not zero VOICE CAL '10' is there, so I need to delete the row with null values. (VOICE, CAL, NULL)

    Network, FL, there is no value is non-null then I should NOT delete this line.

    This table is to have 100 s of this association, we can delete data in a single delete query?

    Or how I can delete rows with nulls for this combination.

    Tab1

    VALUE OF THE NŒUD ID

    VOICE CAL 10
    VOICE CAL NULL
    NETWORK NULL FL

    Thank you

    You can do this in a single DELETE statement (it is not a request), using an EXISTS or IN the subquery.  For example:

    REMOVE table_x m

    WHERE the value IS NULL

    AND THERE ARE)

    SELECT 0

    FROM table_x s

    WHERE s.id = m.id

    AND s.node = m.node

    AND s.value IS NOT NULL

    )

    ;

    If you would care to post CREATE TABLE and INSERT instructions for the sample data, and then I could test it.

  • Separate s processed NULL values in indexes

    http://docs.Oracle.com/CD/B19306_01/server.102/b14220/schema.htm#i20690

    Indices and null values

    NULLthe index values are considered as distinct except when all non - NULL in two or several lines of an index, the values are the same, in which case the lines are regarded as the same. Therefore, UNIQUE i index prevents the lines containing NULL values to be treated as identical. This does not apply if there is not a no - NULL values - in other words, if the lines are fully NULL .

    The bold part: who's trying to tell me that the lines for the NULL indexed lines, that if these indexed 2 NULL values maintain the same values for the rest of the line that oracle treats as unique to them?

    That being said, the bold part is qualified with this statement:

    Therefore, UNIQUE i index prevents the lines containing NULL values to be treated as the same.




    In fact all this 2 average values in a single column being zero, with the rest of the line being exactly the same, is not treated as identical.


    I'm sure that's what the DOC tries to explain.

    Consider that you have a composit index SINGLE a two columns COL1 and COL2. And you want to insert some values like this

    ROWNUM COL1, COL2
    ------- -------- --------
    1 1 NULL
    2 2 NULL
    3 3 NULL
    4 3 NULL

    NULL values in the index are considered to be separate

    This statement indicates that NULL in COL2 values are considered to be UNIQUE values. If the NULL in COL2 ROWNUM 1, 2 are considered to be two different values.

    But the following statement

    except in the case of all values not NULL in two or more rows of an index are the same, in this case, the lines are considered to be identical

    This statement says ROWNUM 3, 4 for COL1, where they have identical values, where the NULL in COL2 value are not considered as UNIQUE values but as identical. That's why the 4 ROWNUM insert will fail with UNIQUE constraint violation.

  • display of the output cursor empty with null values

    I have the below procedure of the State where he is shown the output to the client.

    The requirement now is if the select statement does not return a value any with the input given then output parameter should see NULL values instead of no line at all.


    One method is to get the number of the select query that is written in "open p_out for." And then write the condition as if count is 0 then null other show data.

    Could you please suggest me any other alternative to this.

    Create or replace procedure test (p_empno in number , p_out out sys_refcursor) is
    
    begin
     open p_out for 
     select e.ename, d.deptname, s.sal , p.addr , v.age
      from emp e ,dept d, sal s, padress p , age v
     where e.deptno = d.deptno and d.deptno = s.deptno
     s.sal_id = p.sal_id and p.id = v.id
    and e.empno = p_empno ;
    
     
    exception when others then
     open p_out for 
     select null , null,null,null,null from dual;
    
     
    end test.
    

    Thank you

    Maybe NOT TESTED!

    Select x.ename, x.deptname, x.sal, x.addr, x.age

    of the double

    left outer join

    (select e.ename, d.deptname, s.sal, p.addr, v.age

    from emp e,.

    d Dept,

    SAL s,

    padress p,

    v of the age

    where e.deptno = d.deptno

    and d.deptno = s.deptno

    and s.sal_id = p.sal_id

    and p.id = v.id

    and e.empno = p_empno

    ) x

    1 = 1

    Concerning

    Etbin

    Select x.*

    of the double

    left outer join

    (select *)

    WCP

    where ename = 'ETBIN.

    ) x

    1 = 1

    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    - - - - - - - -
  • Eloqua recommended way to identify records with a null value in a specific field?

    What is the recommended Eloqua the way to identify records with a null value in a specific field in a contact filter.  For example, in the segment 'lead State cleaning-11/21/12', I look for records with a value zero in LeadID and ContactID... How Eloqua recommends to do this?

    Replied to your message here: http://topliners.eloqua.com/message/19075#19075

  • NULL values and cardinality

    Hello Experts,

    I read a slide (five things you probably don't know about SQL) on the values NULL and the cardinality of Tom Kyte. He has demonstrated this indexed column with estimate cardinality evil cause NULL values. However, I do not understand why it causes the estimation of cardinality wrond? You have an idea?

    Party suite comes from the slide. Here's the proof, but is not written why.

    OPS$ % ORA11GR2 tkyte > create table t

    2 20 PCTFREE

    3 as

    4. Select a.*,

    5 case when mod(rownum,100) < = 50

    6 then last_ddl_time

    7 end end_date

    8 object;

    Table created.


    OPS$ % ORA11GR2 tkyte > create indexes t_idx

    2 on t (end_date);

    The index is created.


    OPS$ % ORA11GR2 tkyte > select count (*)

    2 t

    3 where end_date

    4 between to_date ('01 - sep - 2010 "," dd-mon-yyyy "")

    5 and to_date ('30-Oct-2010, ' mon-dd-yyyy "");

    COUNT (*)

    ----------

    36267


    OPS$ % ORA11GR2 tkyte > start

    DBMS_STATS.gather_table_stats 2 (user, 't');

    3 end;

    4.

    PL/SQL procedure successfully completed.


    OPS$ % ORA11GR2 tkyte > select count (*),

    2. count (distinct end_date)

    count (end_date) 3,.

    min (end_date) 4,

    5 max (end_date)

    6 t;

    CNT CNTD CNT2 MIN MAX

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

    72228 703 36850 1 OCTOBER 02 SEP 30.-11


    OPS$ % ORA11GR2 tkyte > set autotrace traceonly explain

    OPS$ % ORA11GR2 tkyte > select *.

    2 t

    3 where end_date

    4 between to_date (' 01-sep-2010', 'dd-mon-yyyy')

    5 and to_date ('30-Oct-2010, 'dd-mon-yyyy');

    Execution plan

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

    Hash value of plan: 1601196873


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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |      | 36024 |  3588K |   339 (1) | 00:00:05 |

    |*  1 |  TABLE ACCESS FULL | T    | 36024 |  3588K |   339 (1) | 00:00:05 |

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

    Information of predicates (identified by the operation identity card):

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

    1 Filter ("End_date" < = TO_DATE (' 2010-09-30 00:00:00 ',' syyyy-mm-dd '))

    HH24:MI:SS') AND 'End_date' > = TO_DATE (' 2010-09-01 00:00:00 ', ')

    'syyyy-mm-dd hh24:mi:ss"))


    OPS$ % ORA11GR2 tkyte > update t

    End_date set 2 =.

    3 to_date ('01 - jan - 9999',' mon-dd-yyyy "")

    4 where End_date is null;

    35378 lines to date.

    OPS$ % ORA11GR2 tkyte > commit;

    Validation complete.


    OPS$ % ORA11GR2 tkyte > start

    DBMS_STATS.gather_table_stats 2 (user, 't');

    3 end;

    4.

    PL/SQL procedure successfully completed.


    OPS$ % ORA11GR2 tkyte > select *.

    2 t

    3 where end_date

    4 between to_date ('01 - sep - 2010 "," dd-mon-yyyy "")

    5 and to_date ('30-Oct-2010, ' mon-dd-yyyy "");

    Execution plan

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

    Hash value of plan: 470836197


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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU).

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

    |   0 | SELECT STATEMENT |       |   175. 18375 |    10 (0) |

    |   1.  TABLE ACCESS BY INDEX ROWID | T     |   175. 18375 |    10 (0) |

    |*  2 |   INDEX RANGE SCAN | T_IDX |   175 |       |     2 (0) |

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

    Information of predicates (identified by the operation identity card):

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

    1 Filter ("End_date" < = TO_DATE (' 2010-09-30 00:00:00 ',' syyyy-mm-dd '))

    HH24:MI:SS') AND 'End_date' > = TO_DATE (' 2010-09-01 00:00:00 ', ')

    'syyyy-mm-dd hh24:mi:ss"))



    Thanks in advance.

    Charlie

    Jonathan has hit it on the head.

    the index has nothing really to do with anything.

    See ask Tom: on queries to external tables, the consistency of data and nothing


    " NULL values and cardinality.


Maybe you are looking for