Manipulation of numbers in a column

Nice day

I need a help to the manipulation with numbers within a column, and I hope you can tell me where to find the answer.

Here's what I have - a "NUMBERS" column, which is a full string column whose numbers are separated by spaces.
-----------------
| THE NUMBERS |
-----------------
| 1 3 5 10 9 |
| 15 2 7 8 1 |
| 2 89 1 0 6 |
__________

What I need is:
1. find the largest number on
2. the main idea is to write all these numbers in a new table - each number in a separate column
3. before write these numbers in separate columns, be deduct each number of as many in a row.

As a result, we have something like this:

-----------------
| THE NUMBERS |
-----------------
| 9 7 5 0 1 |
| 0 13 8 7 14.
| 87 0 88 89 83 |
____________


Thank you in advance.

OK, after seeing the response of ravikumars I got it. This is a way without expression regulare

with tab as
(
select '1 3 5 10 9' num from dual union all
select '15 2 7 8 1' num from dual union all
select '2 89 1 0 6' num from dual
)
select grt-col1, grt-col2, grt-col3, grt-col4, grt-col5
  from (
select greatest(col1, col2, col3, col4, col5) grt, col1, col2, col3, col4, col5
  from (
select to_number(substr(num,1, instr(num, ' ', 1,1))) col1,
       to_number(substr(num,instr(num, ' ', 1,1), instr(num, ' ', 1,2)- instr(num, ' ', 1,1))) col2,
       to_number(substr(num,instr(num, ' ', 1,2), instr(num, ' ', 1,3)- instr(num, ' ', 1,2))) col3,
       to_number(substr(num,instr(num, ' ', 1,3), instr(num, ' ', 1,4)- instr(num, ' ', 1,3))) col4,
       to_number(substr(num,instr(num, ' ', 1,4))) col5
  from tab
       )
       )

Note: If something can be done without regular expression please do it this way. Regular expression comes with a cost.

Tags: Database

Similar Questions

  • Simple query to find the difference between 2 numbers in one column to another column

    Hello

    I would like to know the difference between 2 numbers in same column corresponding to a condition of another column. How do that?

    For example: say I have a table with 3 columns A, B and C.

    A > Varchar2

    B > Varchar2

    C > number

    A B C
    AD1
    BC2
    CB3
    DA4

    I want something like 'column value corresponding C min min (col B) result = (col A) - value of the corresponding C column (number)' without having to write 2 select statements. How do I do that?

    Thanks in advance

    aBBy007



    Notes on the system:

    2-node 11.2.0.3.4 GI/RDBMS running on RHEL5.

    Hello

    It is not very similar to your original question.  It would be better if you asked what you really want in your first post, rather than making people to time writing solutions you want not and can not use waste.  Once you see an answer to this question, will you change the question again?

    Here's a way to do what you asked:

    WITH got_lasts AS

    (

    SELECT val.thread #.

    , MAX (val.sequence #) AS last_standby_seq_received

    MAX (CASE

    WHEN val.applied = "YES".

    THEN val.sequence #.

    END

    ) AS last_standby_seq_applied

    V $ archived_log val

    Join v$ database vdb WE val.resetlogs_change #.

    = vdb.resetlogs_change #.

    GROUP BY thread #.

    )

    SELECT thread #.

    last_standby_seq_received

    last_standby_seq_applied

    last_standby_seq_received

    -last_standby_seq_applied AS total_lag

    OF got_lasts

    ORDER BY thread #.

    ;

  • the list of numbers between two columns

    Hello

    I need the list of numbers between two columns.

    My source table contains the intervals with different ranges and I'm currently thinking dividing them by size.

    I was able to get a solution following the information contained in the Web page:
    http://StackOverflow.com/questions/3971981/get-list-of-numbers-in-between-two-columns

    The solution I've used is based on the following example:
    with t as (   
      select 10 startnum, 15 endnum from dual   
      union all   
      select 18, 22 from dual   
      union all   
      select 10000, 19999999999 from dual   
    )   
    select lvl   
      from (select level lvl  
               from dual  
            connect by level <= (select max(endnum) from t)) a  
      where exists (  
         select 1  
           from t  
          where lvl between t.startnum and t.endnum ) 
    But this doesn't work in my table if I have few and modest intervals (maximum 5 digits range).
    In the example, I was trying to understand why this might be failing, but I do not have a conclusion yet.
    There is something I noticed and that I try to understand, that is:
    If I change this query to:
    with t as (   
      select 10 startnum, 15 endnum from dual   
      union all   
      select 18, 22 from dual   
      union all   
      select 19999999990, 19999999999 from dual   
    )   
    select lvl   
      from (select level lvl  
               from dual  
            connect by level <= (select max(endnum) from t)) a  
      where exists (  
         select 1  
           from t  
          where lvl between t.startnum and t.endnum ) 
    It will increase from 2 to 3 seconds to return results to a few minutes at least (canceled after a few minutes!)

    Thus, using this example to understand if my problem is related to having many between start and end number or if it is linked with having small intervals between large numbers.

    Can someone explain to me why I have this speed of different treatment depending on the value of the interval? And why it takes longer with the small interval?

    I need to apply it to different beaches (from 2 ranges of numbers to 16 range) and in all ranges, I will have small intervals to check.

    For example:
    endnum startnum
    7341 7342
    7422-7423
    7439 7456

    2522200050 2522200054
    2522200146 2522200150

    4216969839880 4216969839884
    4216969839893 4216969839897

    Having this problem I can only ask the first values I have in the picture!

    Best regards
    Ricardo Tomas

    Hi, Ricardo,

    Here's one way:

    WITH       cntr     AS
    (
         SELECT     LEVEL - 1     AS n
         FROM     (
                  SELECT  MAX ( endnum - startnum)     AS max_diff
                  FROM    t
              )
         CONNECT BY     LEVEL <= max_diff + 1
    )
    SELECT  startnum + c.n
    FROM     t
    JOIN     cntr  c      ON   t.endnum  >= t.startnum + c.n
    ;
    

    In your original query, you generate all the numbers from 1 to the highest endnum. You only need enough numbers to cover the range of startnum to endnum. (This method also works if startnum is less than 1).
    Joins are usually faster than EXISTS subqueries.

  • Numbers between two columns

    Hello

    I would like to create sequential numbers between these two columns of the specified table.

    Existing data in the table

    Column1 Column2
    57
    1314
    1819
    2427
    2929

    power required:

    5

    6

    7

    13

    14

    18

    19

    24

    25

    26

    27

    29

    Could someone help me with this please.

    Thank you.

    XQUERY solution:

    with

    data in the form of

    (select 5 Column1, Column2 7 Union double all the)

    Select 13,14 in union double all the

    Select 18,19 Union double all the

    Select 24,27 Union double all the

    Select double 29,29

    )

    Select n

    data,.

    XMLTable)

    "xs:integer ($s) at xs:integer ($e).

    passing of Column1 as "s",.

    Column2 like 'e '.

    columns

    path number n '. »

    )

    /

    N
    ----------
    5
    6
    7
    13
    14
    18
    19
    24
    25
    26
    27

    N
    ----------
    29

    12 selected lines.

    SQL >

    SY.

  • problem using ActiveX to Excel app to determine the numbers of rows/columns

    Hello

    I would like to develop an app, that question is not total. of rows and columns of a data sheet excel and read the data in the same. I made use of a few vi, I found on the forum, but having runing bad to them,.

    can anyone please suggest me what I do wrong? I've never used before activex...

    Hello

    I would have used the free Excel Toolbox. See some examples with it here, here and here.

    The library contains functions of Excel ActiveX premade. This function here would have helped you a lot:

  • Report Total - how does one sum without numbers in the column?

    Hi all

    I have a (classic) report with columns that will display a 1 if a condition is true.
    I replaced the 1 with a cheque .png image and of course, the columns no longer summary.

    Is anyway to keep the images in place and have a total at the end?

    Thank you


    Chris

    You can use a solution as shown here:

    http://HTMLDB.Oracle.com/pls/OTN/f?p=31517:153

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • What is the meaning of the "star/asterisk" against the numbers in the columns ' total and size ""pane in page/folder columns"opinion please?

    I wonder why there are stars / astericks against 15 and 562 in the clip of the screen. Thank you.

    • Means that the number displayed is a summary of the case, as well as the contents of all subfolders
  • How to insert sequence numbers in a column in the table:

    I'm going to the emp table:


    EmpNo enmae job
    1111 ramu Sager
    S.S.E COMER 7658
    8280 GETA INTERN


    modify the table emp Add number of sno

    sno for I must generate 1,2,3...

    How can I do this

    What is

    update emp set sno = somesequence.nextval where sno is null;
    
  • Numbers (insert numbers or text in each column)

    Hello

    I tried very hard to insert a series of numbers or text from a file text and pdf, in my spreadsheet of numbers, but it retains paste all of the data in a single column or row.

    Example: I want to paste following: 123 3 45 2

    That I spend automatically in columnA columnB (123) columnC (45) and column d 2 (3)

    I tried to use TAB instead of SPACE between the numbers, and that does the trick... Only problem is I have a LOT of lines with numbers, so I would take me for always replace SPACE by TAB.

    Is there a way I can stick easily all of my numbers in separate columns?

    He's really hoping someone can help out me

    Best regards

    Michael

    copy the data

    paste into a new Text Edit document,

    Use the search and replace function to replace the spaces with a tab, select all, copy

    paste into an array of numbers

  • How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    Sorry, but for now there no such function to put sequential numbers in the column number drawn.

  • produce a series of numbers to select from the shortcomings of the ID column

    (1)

    Suppose I have a table t that contains lines like this:

    A AND B
    ---------- ----------
    2 4
    6 7

    I would like to use select to produce lines with numbers between a column and column B included
    for each line, like this:

    Select from t...

    2
    3
    4
    6
    7

    (2)

    Suppose I have the ID column that is lacking, I want to get the lowest < N > numbers available between the gaps.
    I did some research and I can find the range of gaps, but I can't get the numbers listed separately, therefore
    I ask the question (1). But is there a direct way for the list instead of going through beaches and the list.

    For example, I have the ID column that has

    2
    5
    6
    7
    9
    2000000

    I would get a select query that produces

    Select...

    3
    4
    8
    10
    11

    I have a way to get a list of 2 to 2000000, then less than what we need to get all the
    numbers of the gap, but who is not effective and may is short-term memory.

    PS: before I post on this group, I did some research already on "connect by", with recursive queries.

    PuraVidaOTN wrote:

    I would like to use select to produce lines with numbers between a column and column B included

    for each line, like this:

    Assuming that no duplicates in the table...

    with t as
    (
     select 2 c1,4 c2 from dual union all
     select 6 c1,7 c2 from dual
    )
    select c1,c2,c1+level-1 c
    from t
    connect by c1+level-1 <= c2
    and prior c1 = c1
    and prior c2 = c2
    and prior sys_guid() is not null;
    
    C1 C2 C
    -- -- -
     2  4 2
     2  4 3
     2  4 4
     6  7 6
     6  7 7 
    

    Suppose I have the ID column that is lacking, I want to get the lowest numbers between the gaps.
    I did some research and I can find the range of gaps, but I can't get the numbers listed separately, therefore
    I ask the question (1). But is there a direct way for the list instead of going through beaches and the list.

    I have a way to get a list of 2 to 2000000, then less than what we need to get all the
    numbers of the gap, but who is not effective and may is short-term memory.

    It's the best way in my opinion...

    Or rather less, you can try outer join...

    Published by: JAC on December 19, 2012 21:28

  • Only download the form type VARCHAR2 column numbers

    Hello
    How can I extract only numbers form varchar2 column type?
    I have data like below.

    25 - Abc
    233 - xyz
    x23A
    9 - dd

    I need following output
    25
    233
    23
    9

    Thank you
    Sujnan

    Hi try this

    SQL> with t as(select '25-Abc' test_string from dual union all
      2  select '233-xyz' from dual union all
      3  select 'x23A' from dual union all
      4  select '9-dd' from dual)
      5  select regexp_substr(test_string,'[[:digit:]]+') from t;
    
    REGEXP_
    -------
    25
    233
    23
    9
    
  • execution of math on a list of numbers using applescript

    I have three columns of numbers in a text file (using BBEdit, impossible to use numbers as there are more than 1 million lines):

    299400 3275700 - 57.9788

    299500-3275700 - 57.9811

    299300 3275600 - 57.9346

    299400 3275600 - 58.0249

    299500-3275600 - 58.0026

    ...

    I simply multiply the last column (what happens to start by "-") by the value of 0.75, but I am confused.

    Beginning AppleScript, so I looked everywhere for example scripts manipulation of numbers but not lucky to have.

    So far, I have this:

    "But I get this error message: error "cannot make characters 16 through 23 of \"tmp_ITFR2000.txt\ text document" application \"BBEdit\" number. "- 1700 characters 16 to 23 of 'class TxtD '"tmp_ITFR2000.txt"to the number of number

    I have to somehow dimension > a number variable?

    Thank you

    Jim

    Use the following line:

    output to found the results as a string as a number object

    (137021)

  • Ahhh need help with numbers - too use to Excel!

    Hello

    I am very new to numbers. I have a spreadsheet and a column, I have the following:-

    AB071602 then below I have AB071604 and so on - I have to do is to change the 07 to the 08 and 16 and 17 on each cell, more than 200. I know there is a way to do this with a formula in excel, but I'm not sure about numbers? I don't want to sit and manually change each cell.

    I also have all these numbers in another column and have a .jpeg at the end of each of them, once again, I'm sure there must be a formula to add it automatically.

    Can someone help me?

    Thank you in advance.

    Assuming you have something like this:

    You can create the file name replacing "0817" "0716" and adding ".jpg" at the end.

    the id of the original photo is in column A and the name of the update file is in column B (in this example.

    B2 = SUBSTITUTE (A2, "0716", "0817") & ".jpg".

    It is a shortcut to select cell B2 and type (or copy and paste it here) the formula:

    = SUBSTITUTE(A2, "0716", "0817") & ".jpg".

    to fill down, select cell B2, copy

    Select the cells B2 at the end of column B (or), and then paste

  • How do you sort a row of numbers?

    Something super simple to do, but I can't see how.  I have a line (not column) and the first cell is a name.  After that, a bunch of cells are numbered.  I want to select all cells with numbers and sort them in order from lowest to highest.  Why isn't it obvious, or am I just dark?

    I think that all spreadsheet applications are designed to sort the columns, not to the lines.  But it is quite easy to achieve what you want. With the selected table, choose table > sort transpose them rows and columns in your menu, the by the numbers in the column, and then choose table > convert rows and columns again.

    SG

Maybe you are looking for

  • Logic pro 9 crashes bouncing

    Yesterday, I upgraded to Sierra and since then I can't bounce to mp3, wav, or more. I click on bounce and logical crashes and that's it. I run an iMac (retina 5K, 27 inches, end of 2014) with 16 GB of memory, and so far, I'm always happy with Logic 9

  • How to disable 10 Windows on a Mac?

    Hi all I made a stupid installation of 10 Windows on a Mac that is too old (early 2009). I have another Mac on which it is possible to run Windows 10 (end of 2013). Can someone help me solve the transmission? Windows forums, you see some information,

  • Satellite Pro A60 had been getting very hot

    My Satellite Pro A60 had been getting very hot (especially on the upper right corner). I also noticed for several months that the fan never stops and it very is nosiy. Is this normal? Thanks for any help you can provide :)

  • help restore OE msgs

    I saved all my OE messages on external drive before a clean install of windows XP - now how do they return?  Thank you!

  • How can I create groups"in my list of Contacts Windows Live Mail?

    I could easily create "Groups" for e-mailing to multiple receipents in Outlook Express.  Now with Windows Live Mail, it seems impossible.  Is there a way to create "groups" in WLM?  And, if so, why their No. easily accessible way to accomplish?