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

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

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

  • 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

  • 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

  • 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

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

  • check NULL values with expressions

    I'm having a problem with an expression that I work with.

    I'm trying to produce a dynamic graph (among other information) that seems to be controlled by a stream - stream artificial is created by a handful of sliders and a wiggle expression.

    The chart is a simple graphic line which works very well. It is created with a null value (MarkPos) that the position is controlled by Captain wiggle expression that I've mentioned before, that follows.

    This next bit is where I have problems:

    I want to score minimum or maximum, the line has reached on the chart by moving a dotted line, one for weak points and the other for the top.

    Focus only on the bottom line;

    I have the following expression associated with the line, which brings together the current position of the value null (MarkPos) and compared with the current position of the line to see if it has all moved further away down, if she has it moving the line to the new pos are lower. However, all that happens is the line following the null value.

    x = thisComp.layer("MarkPos").transform.position.valueAtTime (time) [1];

    y = transform.position.valueAtTime (time) [1];

    z = transform.position.valueAtTime(time-thisComp.frameDuration) [1];

    If (x > y) {}

    [0, x]

    } else {}

    [0, z]

    }

    After a lot of debugging, I now know the issue is with the else statement - what his weight is compensating the to the high movement frame by frame 1 - so how do you define an order of "keep your current position in y ' in this case?

    [0.1] just it back to its original position and it is not possible to just have the ' if(x>y) {[0, x]} "bit without the"else {}.

    Suggestions fo how to fix this, or a better way to do it?

    This should give you the value of y min:

    p = thisComp.layer("MarkPos").transform.position;

    minVal = 999999;

    for (f = timeToFrames (time); f > = 0; f-) {}

    minVal = Math.min (digraph, p.valueAtTime (framesToTime (f)) [1]);

    }

    [value [0], minVal]

    and this should give you the most:

    p = thisComp.layer("MarkPos").transform.position;

    maxVal = - 999999;

    for (f = timeToFrames (time); f > = 0; f-) {}

    maxVal = Math.max (maxVal, p.valueAtTime (framesToTime (f)) [1]);

    }

    [value [0], maxVal]

    Dan

  • How to replace a. null value in obiee report

    Hi gurus,

    In a single column, we get. as the data, how to replace. with the null value

    Please provide your inputs

    Thank you for your time in advance

    Try it out below mentioned formula.

    REPLACE ('service request'. "RS #"(, '.', '') "

  • Null values

    Hello

    NULL values is not the same as a 'space', because a 'space' is a character, but I can't understand this because in my view, there is no way to insert a 'space' in a column.

    If I write this

    insert into table (col1) values (' '); , then I insert a Null value not a space. which means that a 'space' is a 'Null '.

    clarify the problem for me please.

    I'll clarify for you that you're wrong:

    SQL> create table foo (id number, bar varchar2(10));
    
    Table created.                                     
    
    SQL> insert into foo values (1, null);             
    
    1 row created.                                     
    
    SQL> insert into foo values(2, ' ');               
    
    1 row created.                                     
    
    SQL> set null null
    SQL> select * from foo;                             
    
            ID BAR
    ---------- ----------
            1 null
            2
    

    It is perfectly possible to insert a space into a varchar2 column. I hope that you do not have a trigger that makes a trim() on the column, because an empty string in Oracle is indeed the same thing with the null value.

  • Restrict null values

    Hi all

    Can I restrict null values when passing parameters in procedures. can someone explain to me with a small example

    Hello

    Pascale says:
    The table does not allow null values. It throws an exception when the value null is passed IN parameter

    Are you talking about raising of arguments passed to a procedure or a table?

    If a column in the table has a NOT NULL constraint, an error will be reported in the world tries to add a NULL value in this column, or if someone tries to change an existing value with a NULL value.

    I don't know anyway auto to force an error when a procedure is called with a NULL argument. There may not be any built-in mechanism because it is so easy to test the NULL at the beginning of the procedure and explicitly to trigger an error.

  • NULL value in Radio buttons 11.1.1.6.2 OBIEE

    Hello

    I use OBIEE 11.1.1.6.2. When we create fast with radio buttons, I was able to learn a button with a NULL value.
    Even if add a where condition clause to restrict the values Null his watch upward.

    I have the same problem with the check box.

    Is this a Bug in this version?

    Thank your.
    MBVAnand

    Hello

    Uncheck the option 'nullable' for this column in the physical layer and restart presentation services. It should disappear.

    Paul
    http://total-bi.com

  • Oracle Apex open modal dialog URL sent a Null value

    Salvation;

    I am trying to open a url in a modal dialog window, when you click an item in a report, defining a local variable with the primary key using ' $s ('P95_X9', #SEQ_ORDEM_SERVICO #); "return false", but in a javascript call to open the field of modal dialog P95_X9 previously set is sent with a null value.

    Below the call to URL:

    f? p = & APP_ID.:67: & APP_SESSION.:P67_NUMEROOS, P67_HIDENPROJETO: & P95_X9, & P95_PROJE. »

    & P95_X9. -> is sent with a null value.

    How to solve this problem?

    Thank you.

    981949 wrote:
    Salvation;

    I am trying to open a url in a modal dialog window, when you click an item in a report, defining a local variable with the primary key using ' $s ('P95_X9', #SEQ_ORDEM_SERVICO #); "return false", but in a javascript call to open the field of modal dialog P95_X9 previously set is sent with a null value.

    Below the call to URL:

    f? p = & APP_ID.: 67: & APP_SESSION. : P67_NUMEROOS, P67_HIDENPROJETO: & P95_X9, & P95_PROJE. »

    & P95_X9. -> is sent with a null value.

    How to solve this problem?

    Thank you.

    f? p = & APP_ID.: 67: & APP_SESSION. : P67_NUMEROOS, P67_HIDENPROJETO: & P95_X9, & P95_PROJE. »

    Replace above with

    var vUrl = 'f?p=&APP_ID.:67:&APP_SESSION.::::P67_NUMEROOS,P67_HIDENPROJETO:'+$v('P95_X9')+','+$v('P95_PROJE');
    

    now use the many vUrl as necessary!

Maybe you are looking for

  • Control LCD screen flashes on and outside

    HelloI have a 6 yr old HP w15e LCD monitor, it is quite old. But recently, it's showing strange things. Whenever I turn on the power to the monitor with or without the CPU video input, continuous screen blinking on and outside (I think there are two

  • Issue of recovery on Satellite C855

    I've had two of them for repair now. It seems '0' for recovery doesn t work, or he finds a picture of the system for the recovery. One of them refused to do the recovery disc and the other sees readers but they said r empty? But the made recovery dis

  • BIOS problem on dv9500

    I got a CTO dv9500z who owns a F32 BIOS flashed to her. This BIOS, as far as I know, was never for this laptop. When I try to update to all of the BIOS that are listed for that laptop they all, F40, 41 and 42 all say no to this computer. I also leave

  • RT3290 driver for Windows 8 cannot connect wireless Cisco

    I have HP Pavilion g6 (a month old laptop) with Windows8 pre-installed with Ralink RT3290 chipset. I am able to connect to the wireless router NetGear at home but unable to connect to the router Cisco Wireless to work. My friend has Lenevo Windows8 a

  • Replication between two sites with essential Kit more

    Hi allcan anyone confirm that the following scenario is possible?A basic Kit Plus - replication - another essential Kit Plus3 Hosts                                                                      Other 3 HostsIn other words: is it possible to re