Re: Convert a single column string into lines (CSV)

Hi all


I would be grateful for the help here... I don't know it's easy for many, but the research I've done seem to ask for function that do not work in the comic book I'm in.: 10.2.0.5.0

Query is:

SELECT '348419,348420,348421' from DUAL;


Hold out to be:

Select of tb1; *
output:
348419
348420
348421

Of more if you only need the values of o/p in the next line, rather than dealing with each value as separate line, Chr (10) can be used.
If you paste this o/p in excel(.csv/.xls format) each value will be in separate lines and the same technique is very useful for statement of purpose.

with a1 as (SELECT '348419,348420,348421' DOUBLE dat)
Select replace (dat, ',', chr (10)) in a1;

Tags: Database

Similar Questions

  • How to convert a single byte String?

    Purpose:

    Show a result byte on the BB 9900 screen.

    Question:

    How to convert a single byte String?

    Part of the code:

    byte value = con.cpu_config.elementAt (i)

    stop here

    String valuestring = new String (value);

    _rtf. SetText (valueString);

    If you know how to fix it, please share your idea.

    Thank you for your attention,

    String valuestring = new String (new byte [] {value}};)

    _data. Append (valueString);

    _rtf. SetText (_data.toSrting ());

    Solve it.

  • Split a string into lines {< string1 >} | {< string2 >}

    I implemented the Oracle text search in my database. Now I have this query

    Select ctx_thes.syn ('RED', 'MY_THESAURUS') of double;

    the output is displayed as

    {RED} | {MIXTURE OF RED} | {TABLE RED} | {RED}

    and I want to get the words in separate lines, i.e.

    Red

    Mixture of Red

    Red table

    Red wine

    How to split the string into lines?

    SELECT *
      FROM (    SELECT DISTINCT
                       REGEXP_SUBSTR ('{RED}|{RED BLEND}|{RED TABLE}|{RED WINE}',
                                      '({)([A-Z]+ *[A-Z]*)(})',
                                      1,
                                      LEVEL,
                                      'i',
                                      2)
                          val
                  FROM DUAL
            CONNECT BY LEVEL <=
                            REGEXP_COUNT (
                               '{RED}|{RED BLEND}|{RED TABLE}|{RED WINE}',
                               '|')
                          + 1)
     WHERE val IS NOT NULL;
    
  • Convert a single column into multiple lines

    Hi people,

    I have a task to display a single column into multiple lines (for use in LOV)

    For Ex:

    The column consistes of value such as 98,78,67,68,34,90. -It's a unique column values where none of the values can be ' number that is separated by commas

    Then we must view it as

    98
    78
    67
    68
    34
    90
    -under the number of lines (no lines can be ' do not number).

    Thanks in advance

    Try this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select regexp_substr('98,78,67,68,34,90', '[^,]+',1,level) Value
      2    from dual
      3*   connect by level <= regexp_count('98,78,67,68,34,90',',') + 1
    SQL> /
    
    VALUE
    -----------------
    98
    78
    67
    68
    34
    90
    
    6 rows selected.
    

    Thank you!

  • View all in a single column, instead of lines (part 1)

    Hi all

    Help, please...
    How to make my lines of output SQL to display on a single column?
    I have a table: EMP & 3 columns: ID, ENAME, and BIRTHDAY.

    I inserted 3 rows in the table:
    ID ENAME BIRTHDAY
    1 Smith 11/09/1980
    2 Jones 01/01/1981
    3 Baker 02/02/1982

    I want the output of my query in Oracle Developer / ApEx to display like this:
    Employees
    ---------------

    Smith
    11/09/1980

    Jones
    01/01/1981

    Baker
    02/02/1982

    Best regards
    Sunenny

    Published by: user643233 on November 6, 2008 09:10

    Strange formatting. Maybe you could try something like this...

    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    
    SQL> CREATE OR REPLACE TYPE varchar2_table AS TABLE OF VARCHAR2 (4000);
      2  /
    
    Type created.
    
    SQL> SELECT column_value
      2  FROM   emps, TABLE (varchar2_table (NULL, ename, hiredate));
    
    COLUMN_VALUE
    --------------------------------------------------------------------------------
    
    SMITH
    17-DEC-80
    
    ALLEN
    20-FEB-81
    
    WARD
    22-FEB-81
    
    JONES
    02-APR-81
    
    MARTIN
    28-SEP-81
    
    BLAKE
    01-MAY-81
    
    CLARK
    09-JUN-81
    
    SCOTT
    19-APR-87
    
    KING
    17-NOV-81
    
    TURNER
    08-SEP-81
    
    ADAMS
    23-MAY-87
    
    JAMES
    03-DEC-81
    
    FORD
    03-DEC-81
    
    MILLER
    23-JAN-82
    
    42 rows selected.
    
    SQL>
    
  • convert a single column in lines

    Hi gurus,

    I have a GBA test table is id and name.

    Identification number
    name varchar2

    data are like

    name identity

    1 xy
    2 xyy
    3 mm
    4 pp

    Now my requirement is to convert the IDs of unique column in lines

    i, e my output should be Singel lines like:-1,2,3,4

    How to achieve this result.

    I have no idea to make this request.

    Please help guys.

    Thanks in advance.

    Vijay

    Oh, wait, now I see:

    I think that with clause will not work in this State

    You have not the clause at all.

    You can omit this part and change t in your own table name
    I only used it to generate sample data.
    That's why I commented :) - query real, based on the id is generated above: in the query, to indicate what is happening ;)

    As Alex has already pointed out:
    You only need the part from the line 7 (first example) or line 10 (second example)

    Hands a great coffee to Alex

  • How to convert a single column in the primary key column

    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant wrote:
    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant,

    You must assign new values to null values. You can use a sequence to produce the figures in this column.

    Select max (your_unique_column) from your_table; -find the maximum value of this column, so you can start the sequence of this number.

    create sequence seq_for_your_table with XXXX - value max + 1 you have found

    Update your_table set your_unique_column = seq_for_your_table.nextval () where your_unique_column is null

    You can create a primary key on this column.

    Best regards

    Grosbois

    -------------------------------------------------------
    If you answer this question, please mark appropriate as correct/useful messages and the thread as closed. Thank you

  • Arrange the tiles in a column, but multiple lines

    When you have the tiles on The start screen of Metro , you can set the group / block a tile only, but when you want to add the second tile to this group / block, you can put only horizontally (from left or right tile existed), in other words, you can add the column within that group, but you can put the new Tile vertically , under a tile already existence.

    I want to define group / block of tiles with a single column, but multiple lines.
    For example, instead of this:
    xx xx xx    xx
    xx          xx    xx
    to get this:
    xx x xx    xx
    xx x xx    xx
    Screenshot:

    Hi Mike b. II.

    It's normal. You cannot have tiles in groups vertically. Now in your case, if you change the tiles to large tiles, they will stack vertically.

  • Convert different lines in a single column

    DB: 11.1.0.7
    Operating system: Solaris Sparc 5.10

    I have a query that is joining a few tables and give me output like below.
    personnum orgnm
    ======= =======
    The 6 key holder
    9 sales
    3 Mgmt

    I would like to only convert a single as column below.

    col1
    ========
    6, keeper of the key, 9, sales, 3, Mgmt

    I tried with pivot and decode, but not get out that I'm exepcting. Any suggesstions?

    yashwanth437 wrote:
    listagg() function might work.

    LISTAGG is not available in 11.1. It was introduced in 11.2.

    In any case, XML solution:

    with sample_table as (
                          select 6 personnum,'Keyholder' orgnm from dual union all
                          select 9,'Sales' from dual union all
                          select 3,'Mgmt' from dual
                         )
    select  rtrim(xmlagg(xmlelement(e,personnum || ',' || orgnm,',').extract('//text()')),',') col1
      from  sample_table
    /
    
    COL1
    ---------------------------
    6,Keyholder,9,Sales,3,Mgmt
    
    SQL> 
    

    SY.

  • Convert lines to a single column

    Hi all


    Need help, I have a table where I want the output to a single column

    ex: Select in t1. *
    the query result_

    rownum col_1
    1 8217
    2 6037
    3-5368
    4 5543
    5 5232

    I want the result to be: * 8217,6037,5368,5543,5232 *.


    Thank you for your help in advance.

    I search the web but couldn't find a solution that is easily understandable.

    WM_CONCAT is not documented, so not everyone would want to use it in production code.
    However, SYS_CONNECT_BY_PATH might work:

    SQL> create table t as
      2  select 1 rn, 8217 count_1 from dual union
      3  select 2, 6037 from dual union
      4  select 3, 5368 from dual union
      5  select 4, 5543 from dual union
      6  select 5, 5232  from dual;
    
    Table created.
    
    SQL> select * from t;
    
           RN    COUNT_1
    --------- ----------
            1       8217
            2       6037
            3       5368
            4       5543
            5       5232
    
    5 rows selected.
    
    SQL>
    SQL> select rownum
      2  ,      ltrim(sys_connect_by_path(count_1, ','), ',') count_1
      3  from   t
      4  where  connect_by_isleaf=1
      5  start with t.rn=1
      6  connect by t.rn  = prior t.rn+1;
    
     ROWNUM
    -------
    COUNT_1
    -------------------------------------------------------------------------------------
          1
    8217,6037,5368,5543,5232
    
    1 row selected.
    

    Or LISTAGG on 11.2:

    SQL> select listagg(count_1, ',') within group (order by rn) agged from t;
    
    AGGED
    -------------------------
    8217,6037,5368,5543,5232
    
    1 row selected.
    

    I really hope that you do not really use ROWNUM as column name? I used instead RN...

  • Divided into a single column

    Hello

    I need to split into single column in the format below:

    SELECT '6500,1100,3200,1233,9000' FROM DUAL;

    Result:

    6500

    1100

    3200

    1233

    9000

    For 11g and above:

    Select regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) suite

    of the double

    connect by level<= regexp_count('6500,1100,3200,1233,9000',="" ',')="" +="">

    For 10g:

    Select regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) suite

    of the double

    connect by level<= length="" (regexp_replace="" ('6500,1100,3200,1233,9000',="" '[^,]+'))="" +="">

    or (if there is no empty entries):

    Select regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) suite

    of the double

    connect regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) is not null

    RESULT
    6500
    1100
    3200
    1233
    9000

    5 selected lines.

  • Single line based on two columns and a single column

    Dear members,

    I have a table that contains duplicate rows, for which a request should be able to extract the unique row in the table. Here the unique is not based on a single column, but it should be in two columns and also check on the uniqueness on a column.

    create table addr (varchar2 (10) firstname, lastname varchar2 (10), area varchar2 (3));

    insert into values addr ('bob', 'james', 1');
    insert into values addr ('bob', 'james', 1');

    insert into values addr ('harry', 'bert', ' 1');
    insert into values addr ('jimmy', 'bert', ' 1');

    insert into values addr ('sam', 'mac', '1');
    insert into values addr ('sam', 'Knight', '1');

    insert into values addr ('tom', 'sand', '1');
    insert into values addr ("cat", "mud", "1");


    The query output must contain 3 lines.

    Bob - james
    Harry - bert or jimmy - bert [or the other of them], but not both
    -Mac or sam - Sam Knight [or the other of them], but not both
    Tom - sand
    Cat - mud

    SELECT firstname, lastname as total area WHERE addr = '1' GROUP by firstname, lastname; It takes no duplication of single column...

    Any suggestions...
    SQL> with t_data
    as
    (
    select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
    select 'bob', 'james', '1' from dual union all
    select 'harry', 'bert', '1' from dual union all
    select 'jimmy', 'bert', '1' from dual union all
    select 'sam', 'mac', '1' from dual union all
    select 'sam', 'knight', '1' from dual union all
    select 'tom', 'sand', '1' from dual union all
    select 'cat', 'mud', '1' from dual
    )
    SELECT
            firstname,
            lastname,
            area
    FROM
            (
                    SELECT
                            t.*,
                            row_number() over(partition BY firstname order by 1) rn,
                            row_number() over(partition BY lastname order by 1) rn1
                    FROM
                            t_data t
            )
    WHERE
            rn     = 1
    AND rn1 =1 ;  
    
    FIRSTNAME       LASTNAME        AREA
    --------------- --------------- ----------
    bob             james           1
    cat             mud             1
    jimmy           bert            1
    sam             knight          1
    tom             sand            1
    
    SQL>
    
  • Convert a single number to a hexadecimal string of 32-bit and exchange the high and low bytes

    I need to convert a number single precision floating decimal to hexadecimal format of 32 bits, share the high and low bytes and that convert a hexadecimal string.  I tried to use the 'Word of Swap' function but it seems to have no effect on the unique number.

    Then

    A single decimal number of entry: 100

    Convert 32 bit hexadecimal string with the low byte first: 0000 42 8

    Anyone have any ideas?

    Thank you

    Slightly lighter, try to cast U32 and exchange words. Same difference.

    (apparently, exchanging words is a NOOP for SGL, but still accepts SGL without constraint. Interesting...)

  • Convert the column values into buckets

    Hello

    Please help me to convert the column values into buckets.
    I have the values of the columns in the following way.


    Age of Orderdate * 9 10 12 14 15 18 19 20 21 22 26 27 28 29 33 34 40 45 * and so on



    But the requirement is the column values should be displayed in form

    Age by order date * 15 1 2 3 4 5 6 7 8 9 10 11 - 16-20 21-25, 26-30 30 + *.


    Please someone give me the solution.

    Thanks in advance.

    Hervé Rama

    Hi Richard,

    Just to double check, you have Setup buckets for 1, 2, 3, 4, 5, 6, 7 and 8 individually (each with a fair value). The problem is that you simply do not have all data fall into buckets above, correct?

    If this is the case, it looks like has been answered your original question. If so, the label would assign 'Proper' points by clicking on the button label correct next to the appropriate response and open a new thread with your new question. The reason why I say this is it will help other people who have a similar bucket question to your solution, without complicating the issue with subsequent questions.

    If you can post a separate thread, I'd be more than happy to help you with your secondary problem.

    Best regards

    -Joe

  • Merge multiple columns into a single column?

    Hello

    I need to perform queries dynamically and the return values. I need to retrieve the values of the queries in a single column only by concatenating multiple columns. I can't use the PL/SQL in my scenario.
    is it possible to run a query and the result will be extracted in a single column (multiple column values must be concatenated)?

    Thank you
    Raja.
    SELECT rtrim(extract(xmltype(REPLACE(column_value,'
    

    Check this box... Copy it directly to this

    Ravi Kumar

Maybe you are looking for

  • JAWS 12 and 13 do not work correctly with Firefox 10.0.4 ESR

    I have two JAWS 12 and 13.0.852 installed on Windows 7 64 bit. My Firefox version is 10.0.4 ESR. The cursor of the JAWS virtual machine, but when I press the top and bottom arrows on a web page, nothing is spoken. It does not seem to recognize the ta

  • How to remove the shortcut from Toshiba offers?

    I got a new computer, and it had a link to "Toshiba offers" in the start menu. I managed to delete the icon and the file but the link is still there and I can't find out how to get rid of. Here is a picture. If he were anywhere else on the start bar,

  • Help with the calculations of time

    I tried several searches but can't seem to find what I need to do. I need to read a file with two columns, the first column is the time of an event. Then I need to calculate the time between each event (row). I know I have to use a loop to read the f

  • How can I Ease of Access Center change\cancel?

    Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: How I change\cancel it back? I played with him, and now I don't know how to restore it. Help! You have problems with programs Error messa

  • How can I add a 'Record number' column in a folder that contains the music?

    How can I add a 'Record number' column for my music files?  It does not appear as a column I add when I right click on the folder in its display of details.  Zune program uses this file attribute.