History of backfilling with non-null values

Hi gurus,

in Oracle 11 g, which would be the best way to update a null with the next available non-null value?

For example: in the code below, I need to update the null in 20130201 record (key = 1) (key date) with a value of 100 available at the next available date IE 20130203.
Same key = 3 value will be updated with key = 4 value i.e. 200.
1,ABCD, 20130201, NULL
2,ABCD,20130203, 100
3,ABCD, 20130205, NULL
4, ABCD,20130207, 200
Thank you
S
with t as (
           select  tbl.*,
                   last_value(nvl2(c4,c1,null) ignore nulls) over(order by c1) prev_c1,
                   last_value(c4 ignore nulls) over(order by c1) prev_c4,
                   first_value(nvl2(c4,c1,null) ignore nulls) over(order by c1 rows between current row and unbounded following) next_c1,
                   first_value(c4 ignore nulls) over(order by c1 rows between current row and unbounded following) next_c4
             from  tbl
          )
select  c1,
        c2,
        c3,
        c4,
        case
          when c4 is not null then c4
          when c1 - prev_c1 < next_c1 - c1 then prev_c4
          else next_c4
        end new_c4
  from  t
/

        C1 C2           C3         C4     NEW_C4
---------- ---- ---------- ---------- ----------
         1 ABCD   20130201                   100
         2 ABCD   20130203        100        100
         3 ABCD   20130205                   200
         4 ABCD   20130207        200        200

SQL> 

SY.

Tags: Database

Similar Questions

  • 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

  • How to leave db field with a Null value if no value is entered in the form?

    I have a short form that has optional fields. If the optional fields are not filled in the form, I want to leave the field with a Null value in the SQL db. SQL columns allow Null, but whenever this code runs, it seems to insert a space rather than leave the field with a null value. I forget to do?

    Here is the solution...

  • Count of non-null values

    I have a column of data, and there are values and values NULL how would count just the values on a resume?
    Everything I tried to give me the total number of lines not the non-null values...

    TIA

    Rose

    should count the element_name whose values are not null.

  • Need to get the latest news for a group-max (value) of the non-null values

    Hello

    Here is my table and data

    SQL > desc method

    NUMBER OF SEQ_ID
    EMP_ID NUMBER
    ISSUE GUID
    FIRST NAME VARCHAR2 (30)
    LAST_NAME VARCHAR2 (30)
    E-MAIL VARCHAR2 (45)
    PHONENO VARCHAR2 (30)

    SQL > Select * method;

    SEQ_ID EMP_ID GUID FIRST_NAME LAST_NAME EMAIL PHONENO
    ------ - ----- ---- --------- --------------------------------------------------- ----------------------------------------- ------------------------------
    1 100 20 RAJA HHH 686678
    2 100 20 [email protected]
    3 100 20 RAJA 134555
    4 100 20 HAPPY [email protected]
    5 200 20 RAM
    6 200 20 JJJ 2345667
    7 200 20 RM GGG [email protected] 1234557
    8 200 20 [email protected] RRR

    8 selected lines


    I want the latest news on the employee, the group id comibnation for the rest of the columns.

    So I want to get the following result.

    100 20 RAVI HHH [email protected] 134555

    200 20 RRR GGG [email protected] 1234557


    If you note here for the family name, we take the previous value non-zero value Eg HHH column and is the same for all columns.

    It's the value of line max (seqid) for empid, combination of guid and if the column values are null, we must get the previous maximum value non-zero.

    The seqid is also there that the sequence.

    Please help me to get the result set.

    Thanks in advance.

    mjhraja.
    SQL> select emp_id, guid, max(first_name) first_name, max(last_name) last_name
      2    , max(email) email, max(phoneno) phoneno
      3  from (
      4    select emp_id, guid
      5      , first_value (first_name ignore nulls)
      6          over (partition by emp_id, guid order by seq_id desc) first_name
      7      , first_value (last_name ignore nulls)
      8          over (partition by emp_id, guid order by seq_id desc) last_name
      9      , first_value (email ignore nulls)
     10          over (partition by emp_id, guid order by seq_id desc) email
     11      , first_value (phoneno ignore nulls)
     12          over (partition by emp_id, guid order by seq_id desc) phoneno
     13    from emp_info
     14  )
     15  group by emp_id, guid
     16  /
    
        EMP_ID GUID FIRST_NAME LAST_NAME  EMAIL                PHONENO
    ---------- ---- ---------- ---------- -------------------- ----------
           100   20 RAVI       HHH        [email protected]         134555
           200   20 RRR        GGG        [email protected]       1234557
    
    SQL> 
    
  • Several lines in duplicate with the null value displayed in the combined analysis rpt

    Dear all,

    Our requirement is to display users open tasks (my open tasks) on the home page. So I created a report called open my tasks.

    The columns to display are subject, account name, due date, owner. If I use only the 'activities' notification area, and then I can not retrieve tasks that have NULL of the account name. SOD ignore and filter the tasks with the NULL account name if I display the name of the account.

    So I used a combined analysis of activity report activity with itself i.e. area statement. All columns except account name in one of them where I used "instead of the name of Account.Account.

    It now also displays tasks with NULL account name. But there is another question. These activities when there is an account name, display double - double rows - an account name and othet without account name (for example, NULL).

    Please can you help how to solve above or meet the requirement in an alternative way?

    Thank you
    Niraj

    VR;

    (1. any activity with account) + (2. All activities - 3. Activities with account)

    1 account name because it is
    2 maintain a column empty "
    3 write the instruction box and change the name of the account by white ")

    Dinesh

  • Return the first line with a non-null value in a column

    Hey there, gurus. Can someone give me a hand with this?

    I have a table with six columns: Class_ID, Course_ID, start_date, Last_Name, First_Name, company. When our students take a class and will fill in an evaluation form, they fill in the Class_ID Last_Name First_Name, and Company. The Course_ID and Start_Date are filled automatically based on the Class_ID.

    I am trying to generate a report that contains Class_ID, Course_ID and Start_Date, PLUS the value of the first not null in the column of company for a combination given to the three first columns. Here is my SQL that does not quite do the trick:

    Select distinct c.class_id, c.course_id, c.start_date, p.company
    class c, person p, student s
    where substr (c.course_id, 1, 3) = "OBI".
    and c.start_date > = SYSDATE-30
    and c.class_id = s.class_id
    and s.pid = p.pid
    order start_date, company, class_id, course_id

    At present, if in a given class, a student entered "CCCC" under the name of the company and another entry "Collin Co Comm Coll" and another between "Collin College", I would get three rows of this class when you use the SQL above. I want just one line. I don't really like which company names gets selected - one of them will be great for our needs. I just need to see a line for each class_id and single value that some students entered the area of the company. And I guess I have to say that if no student fills in the name of the company I need to see the value null, because I need to see the line no matter what.

    Looks like some sort of funky outer join or a coalesce, but it is beyond my ability to understand.

    Now I get this:
    During class 1234 SQL271 Date 22/07/2013 company XYZ Inc.
    Made up of class 1234 SQL271 Date 22/07/2013 company XYZ
    1234 SQL271 Date 22/07/2013 company XYZ, class

    What I want:
    Class 1234 SQL271 22/07/2013 Date course XYZ Inc. or one of the other 2

    Thanks in advance!
    select c.class_id, c.course_id, c.start_date, max(p.company) company
    from class c, person p, student s
    where substr(c.course_id,1,3) = 'OBI'
    and c.start_date >= SYSDATE-30
    and c.class_id = s.class_id
    and s.pid = p.pid
    group by c.class_id, c.course_id, c.start_date
    order by class_id, start_date, course_id
    

    Or if you want to list all businesses, you can use LISTAGG if you're on the latest version of ORACLE

  • Use Insert all but want only to insert records for non-null values

    Hi, New here and could use some help with my sql statement.  I have a portfolio with denormalized data table that has been inserted via .csv file.  It is a contract with a base, options and extensions.  I need to create a contract record, then a separate record in the table for each base/option/extension contract Details.  I use INSERT ALL so I maintain the CONTRACT_ID for the secondary table.  My problem is that my statement puts a line in the table of details for the null records, that I don't want.  (i.e. 123 contract has a Base, Option 1, Option 2 and Option 3, but I'm getting a line for these lines with dates more null for Option 4, Ext 1, Ext 2, Ext 3 and Ext 4).  I want to insert only when the % CTRT_STRT_DT is NOT NULL.  It will be different for each contract.  Where should I put the IS NOT NULL statement?  Here is my complete insert statement:

    -Contract data

    INSERT ALL

    IN LRTC)

    CTRT_ID,

    PRGRM_OFC_TYP_CD,

    CTRT_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    PRGRM_OFC_TYP_CD,

    SPLS_SRVS_DESC,

    SYSDATE)

    -Contract detail for another period of performance data

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    "Other."

    OTHER_CTRT_STRT_DT,

    OTHER_CTRT_END_DT,

    OTHER_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Contract detail data for the reference period of performance

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    'Base ',.

    BASE_CTRT_STRT_DT,

    BASE_CTRT_END_DT,

    BASE_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Option 1 execution time-out

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    "Option 1",

    OPT1_CTRT_STRT_DT,

    OPT1_CTRT_END_DT,

    OPT1_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Option 2 execution time-out

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    'Option 2',

    OPT2_CTRT_STRT_DT,

    OPT2_CTRT_END_DT,

    OPT2_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Option 3 lead time

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    'Option 3',

    OPT3_CTRT_STRT_DT,

    OPT3_CTRT_END_DT,

    OPT3_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Option 4 execution time-out

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    'Option 4',

    OPT4_CTRT_STRT_DT,

    OPT4_CTRT_END_DT,

    OPT4_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Extension 1 execution time-out

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    'Extension 1',

    EXT1_CTRT_STRT_DT,

    EXT1_CTRT_END_DT,

    EXT1_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Extension 2 execution time-out

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    '2 Extension',

    EXT2_CTRT_STRT_DT,

    EXT2_CTRT_END_DT,

    EXT2_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Extension 3 lead time

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    '3 Extension',

    EXT3_CTRT_STRT_DT,

    EXT3_CTRT_END_DT,

    EXT3_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    -Data contract detail for Extension 4 execution time-out

    IN CTRT_DTLS)

    CTRT_ID,

    CTRT_STAT_CD,

    CTRT_PER_NME,

    CTRT_STRT_DT,

    CTRT_END_DT,

    CTRT_CURR_AMT,

    CTRT_NO,

    CTRT_VNDR_NME,

    CREN_DT)

    VALUES)

    CTRT_ID_SEQ. NEXTVAL,

    1,

    '4 Extension',

    EXT4_CTRT_STRT_DT,

    EXT4_CTRT_END_DT,

    EXT4_CTRT_CURR_AMT,

    CTRT_NO,

    CTRTR_NME,

    SYSDATE)

    SELECT

    PRGRM_OFC_TYP_CD,

    SPLS_SRVS_DESC,

    CTRT_NO,

    CTRTR_NME,

    To_date(PER_OF_PFRM_OTHER_ST_DT,'MM/DD/YYYY') as OTHER_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_OTHER_END_DT,'MM/DD/YYYY') as OTHER_CTRT_END_DT,

    CUR_VAL_BY_POP_OTHER_AMT as OTHER_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_BASE_ST_DT,'MM/DD/YYYY') as BASE_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_BASE_END_DT,'MM/DD/YYYY') as BASE_CTRT_END_DT,

    CUR_VAL_BY_POP_BASE_AMT as BASE_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_OPT1_ST_DT,'MM/DD/YYYY') as OPT1_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_OPT1_END_DT,'MM/DD/YYYY') as OPT1_CTRT_END_DT,

    CUR_VAL_BY_POP_OPT1_AMT as OPT1_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_OPT2_ST_DT,'MM/DD/YYYY') as OPT2_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_OPT2_END_DT,'MM/DD/YYYY') as OPT2_CTRT_END_DT,

    CUR_VAL_BY_POP_OPT2_AMT as OPT2_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_OPT3_ST_DT,'MM/DD/YYYY') as OPT3_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_OPT3_END_DT,'MM/DD/YYYY') as OPT3_CTRT_END_DT,

    CUR_VAL_BY_POP_OPT3_AMT as OPT3_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_OPT4_ST_DT,'MM/DD/YYYY') as OPT4_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_OPT4_END_DT,'MM/DD/YYYY') as OPT4_CTRT_END_DT,

    CUR_VAL_BY_POP_OPT4_AMT as OPT4_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_EXT1_ST_DT,'MM/DD/YYYY') as EXT1_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_EXT1_END_DT,'MM/DD/YYYY') as EXT1_CTRT_END_DT,

    CUR_VAL_BY_POP_EXT1_AMT as EXT1_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_EXT2_ST_DT,'MM/DD/YYYY') as EXT2_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_EXT2_END_DT,'MM/DD/YYYY') as EXT2_CTRT_END_DT,

    CUR_VAL_POP_EXT2_AMT as EXT2_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_EXT3_ST_DT,'MM/DD/YYYY') as EXT3_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_EXT3_END_DT,'MM/DD/YYYY') as EXT3_CTRT_END_DT,

    CUR_VAL_BY_POP_EXT3_AMT as EXT3_CTRT_CURR_AMT,

    To_date(PER_OF_PFRM_EXT4_ST_DT,'MM/DD/YYYY') as EXT4_CTRT_STRT_DT,

    To_date(PER_OF_PFRM_EXT4_END_DT,'MM/DD/YYYY') as EXT4_CTRT_END_DT,

    CUR_VAL_BY_POP_EXT4_AMT as EXT4_CTRT_CURR_AMT

    OF CTRT_HLDG A, PRGRM_OFC_TYP_LKUP B

    WHERE UPPER (A.OFC_NME) = UPPER (B.PRGRM_OFC_TYP_NME);

    Thanks for any help.

    Chris

    You're close.  Basically, you add one when befire each Inserts lines.  Something like:

    INSERT ALL

    When the ctrt_id is not null then

    IN LRTC (PRGRM_OFC_TYP_CD, CTRT_NME, CTRT_ID, CREN_DT)

    VALUES (CTRT_ID_SEQ. NEXTVAL, PRGRM_OFC_TYP_CD,

    SPLS_SRVS_DESC, SYSDATE)

    -Contract detail for another period of performance data

    When the OTHER_CTRT_STRT_DT is not null then

    IN (CTRT_ID, CTRT_STAT_CD, CTRT_PER_NME, CTRT_DTLS

    CTRT_STRT_DT, CTRT_END_DT, CTRT_CURR_AMT,

    CTRT_NO, CTRT_VNDR_NME, CREN_DT)

    VALUES (CTRT_ID_SEQ. NEXTVAL, 1, 'Other', OTHER_CTRT_STRT_DT,

    OTHER_CTRT_END_DT, OTHER_CTRT_CURR_AMT,

    CTRT_NO, CTRTR_NME, SYSDATE)

    -Contract detail data for the reference period of performance

    When the BASE_CTRT_STRT_DT is not null then

    IN (CTRT_ID, CTRT_STAT_CD, CTRT_PER_NME, CTRT_DTLS

    CTRT_STRT_DT, CTRT_END_DT, CTRT_CURR_AMT,

    CTRT_NO, CTRT_VNDR_NME, CREN_DT)

    VALUES (CTRT_ID_SEQ. NEXTVAL, 1, 'Base', BASE_CTRT_STRT_DT,

    BASE_CTRT_END_DT, BASE_CTRT_CURR_AMT, CTRT_NO,

    CTRTR_NME, SYSDATE)

    You may need to adjust my predicates, but it should give you the idea.

    John

  • Complete with matching null values

    Hi all
    Take into consideration the following:

    create table X_T2
    (
      COL1 VARCHAR2(2),
      COL2 VARCHAR2(2)
    )
    insert into x_t2 (COL1, COL2)
    values ('1', 'A');
    
    insert into x_t2 (COL1, COL2)
    values ('2', '');
    
    insert into x_t2 (COL1, COL2)
    values ('3', '');
    
    insert into x_t2 (COL1, COL2)
    values ('4', '');
    
    insert into x_t2 (COL1, COL2)
    values ('5', '');
    
    insert into x_t2 (COL1, COL2)
    values ('6', '');
    
    insert into x_t2 (COL1, COL2)
    values ('7', 'B');
    
    insert into x_t2 (COL1, COL2)
    values ('8', '');
    
    insert into x_t2 (COL1, COL2)
    values ('9', '');
    
    insert into x_t2 (COL1, COL2)
    values ('10', '');
    
    insert into x_t2 (COL1, COL2)
    values ('11', '');
    
    insert into x_t2 (COL1, COL2)
    values ('12', 'C');
    
    insert into x_t2 (COL1, COL2)
    values ('13', '');
    
    insert into x_t2 (COL1, COL2)
    values ('14', '');
    
    insert into x_t2 (COL1, COL2)
    values ('15', '');
    
    insert into x_t2 (COL1, COL2)
    values ('16', '');
    
    insert into x_t2 (COL1, COL2)
    values ('17', 'D');
    
    insert into x_t2 (COL1, COL2)
    values ('18', '');
    
    insert into x_t2 (COL1, COL2)
    values ('19', '');
    
    insert into x_t2 (COL1, COL2)
    values ('20', '');
    Required result:
    1     A
    2     A
    3     A
    4     A
    5     A
    6     A
    7     B
    8     B
    9     B
    10     B
    11     B
    12     C
    13     C
    14     C
    15     C
    16     C
    17     D
    18     D
    19     D
    20     D
    Any ideas?

    Oracle 11g


    Thanks in advance,
    Alexander.

    Hello, Alexander.

    Here's one way:

    SELECT    col1
    ,       LAST_VALUE (col2 IGNORE NULLS)
               OVER (ORDER BY  LPAD (col1, 2))     AS c2
    FROM       x_t2
    ORDER BY  LPAD (col1, 2)
    ;
    

    a.Stoyanov wrote: Hi all,.
    Take into consideration the following:

    create table X_T2
    (
    COL1 VARCHAR2(2),
    COL2 VARCHAR2(2)
    )
    
    insert into x_t2 (COL1, COL2)
    values ('1', 'A');
    ...
    

    If you want to '2' and '3' in front of '10' and 11', then you might consider col1, a NUMBER, rather than a VARCHAR2, or add a constraint (and possibly a trigger) to make sure he always has 2 characters.

    Please include the information and sample version; It's very useful!
    You didn't say if you have Oracle 11.1 or 11.2. From 11.2, there is another way to specify IGNORE NULLS; but as noted above will work in both versions (or any version starting with Oracle 10.1).

  • Find columns with only NULL values

    I have a list of tables around 30 in number. Among them i need to generate a report with Table Name and Column Names, for which all values are NULL.
    In other words, i need to find all the columns for which all the values are NULL.
    
    
    I thought of dealing it with cursors, and comparing the total count with null count in each column. But i need to loop "Number of columns" times. Is there any better way to do this?

    If your statistics are up to date, you can use the datadictionary:

    select tab.table_name
    ,      tab.num_rows
    ,      col.column_name
    ,      case
             when tab.num_rows = col.num_nulls then '*100% NULL*'
             else to_char(col.num_nulls)
           end num_nulls
    from   user_tab_columns col
    ,      user_tables tab
    where  col.table_name = tab.table_name
    and    tab.num_rows > 0
    and    tab.table_name IN (YOUR_TABLE NAMES)
    order by tab.table_name, column_id;
    

    Set the query for your needs.

  • Number of rows in each partition is displayed with a NULL value for a table partitioned in user_tab_partitions. Why?

    I created a table and partitioned on the date of the entry and added a local partitioned index.

    Now, I use a query to extract "num_rows" of user_tab_partitions to know the number of rows in each partition.

    Getting this value as null num_rows, wonder why?

    After looking to explain the Plan after interrogation ("select * from my_table1 where entry_date = 1 January 2015" ;))

    to find out if she actually partitioned table and its data in different partitions, I interpreted in effect because the query plan had a line like Partition_range (Single).

    My Question is:

    (a) is actually partitioned data (have I misinterpreted the Explain plan)

    (b) why is the num_rows null column in the query (Pasted below)

    (c) also in addition what difference it would have been if I had created a Global Index instead of the Local Index in my case?

    The following code Snippet:

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

    create the table my_table1
    (
    roll_no number constraint my_table1_pk primary key,
    date of entry_date
    )
    partition of range (entry_date)
    (
    PARTITION data_p1 VALUES LESS THAN (TO_DATE (December 31, 2014 ',' DD-MM-YYYY ""));
    PARTITION data_p2 VALUES LESS THAN (MAXVALUE)
    );


    create an index only my_table1_indx on my_table1 (entry_date) local;

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

    I now insert two lines:
    insert into my_table1 values (1, to_date ('01-01-2015', ' dd-mm-yyyy'));
    insert into my_table1 values (2, to_date('01-02-2015','dd-mm-yyyy'));

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

    These have been inserted successfully, now using the query below shows num_rows column as null. I don't know why?

    SELECT table_name, num_rows, high_value, nom_partition
    Of user_tab_partitions
    where table_name = 'MY_TABLE1 '.
    ORDER BY table_name, nom_partition;

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


    (a) is actually partitioned data (have I misinterpreted the Explain plan)

    Yes, it is partitioned. You can query this particular partition SELECT * FROM my_table1 (data_p1) PARTITION to check that.

    (b) why is the num_rows null column in the query (Pasted below)

    As already mentioned that you have not collected statistics.

    (c) also in addition what difference it would have been if I had created a Global Index instead of the Local Index in my case?

    In fact, you have created two types of indexes without knowing (can be)! One is not partitioned (although this column is not partition key) and another is partitioned (LOCAL). They are MY_TABLE1_PK and MY_TABLE1_INDX. You can check that USER_INDEXES.

    You can read this article to get an early jump on the partitioning of decision. Partition: Partition decisions

  • the non-null values insert select

    Please could you help me on this:

    INSERT INTO new_table (ID, hobby, country, internal_id, cat)

    SELECT ID, hobby, country internal_id,

    Max (CASE cat WHEN = 'ben' THEN 1

    WHAT cat = 'ale' THEN 2

    WHAT cat = 'inf' THEN 3

    WHAT cat = "cad" THEN 4

    WHAT cat = 'juv' THEN 5

    WHAT cat = 'sen' THEN 6

    WHAT cat = 'teacher' THEN 7

    END)

    Ancienne_table GROUP BY ID, hobby, country, internal_id;

    the lines on ancienne_table have duplicates regs as follows:

    IDCountryHobbyInternal_IDCAT
    1OmanRugby Union63180Juv
    1OmanRugby Union63180Teacher
    1OmanRugby Union63180Juv

    the request requires the output as follows:

    IDCountryHobbyInternal_IDCAT
    1OmanRugby Union631807

    because cat = 'juv' (5) is less cat =' teacher (7).

    all columns are not null and the primary key of the new_table is ID + hobby

    The script displays the following output:

    01400 00000 - 'impossible to insert NULL into (%s)' because does not recognize the function max.

    Thanks in advance.

    Kind regards.

    Actually there are values not in the range of cat. There is an error in the old data table.

    I proceeded to remove the lines out of reach in the cat because column that are not relevant in this case.

    The parameters I use Oracle are:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    PL/SQL Release 11.2.0.1.0 - Production

    "CORE 11.2.0.1.0 Production."

    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    Thank you very much. You are so helpful.

    Kind regards.

  • parameter with a null value

    I write this code to report and

    I put parameters to filter data when the user needs data

    but when he needs all the data in the report returns all data

    but the following code returns all the data when I put the settings

    SELECT get_full_name (a.user_stud_id), a.amount, a.user_stud_id, a.amount_detial,

    a.std_cost_id, a.grade_stud, a.twread_number, a.twread_date, a.user_move_id,

    a.move_date, a.safe_id, a.safe_name

    OF std_main_money one

    where

    std_cost_id =: P1 or: P1 is null

    and Grade_stud =: P2 or: P2 is null

    ORDER BY std_cost_id, Grade_stud, move_id, user_stud_id

    Hello

    If std_cost_id and Grade_stud are not null columns, you can also do

    SELECT get_full_name (a.user_stud_id), a.amount, a.user_stud_id, a.amount_detial,

    a.std_cost_id, a.grade_stud, a.twread_number, a.twread_date, a.user_move_id,

    a.move_date, a.safe_id, a.safe_name

    OF std_main_money one

    where

    std_cost_id =nvl(:P1,std_cost_id)

    and Grade_stud =nvl(:P2,Grade_stud)

    ORDER BY std_cost_id, Grade_stud, move_id, user_stud_id

    Best regards

  • How can - I crop, scale, rotation, overlay a .jpg with non-standard values image

    I want to do the following to the .jpg images:

    1. cultures with white border for the photo to look like a photo (instead of only black).

    2. photo scale (with white border) to 70% of the size.

    3. turn cropped across the photo 10 degrees to the right or to the left (instead of only + / 90).

    4. superimpose the image obtained in video.

    I used to be able to do it with Adobe Premiere 6.5, but with first Elements 10

    I don't know how to do the following steps. Any suggestions?

    -Frank

    Mattes of color are found under the button new item on the media Panel.

    Rotation is in the query parameters in the properties panel, which can be opened by right-clicking on a clip on the timeline and selecting view properties. (I don't know where Bill is to see fixed effect either).

    Step by step instructions on most of these things can be found in my books, if you are interested, of course.

    http://Muvipix.com/pe10.php

  • 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.

Maybe you are looking for