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

Tags: Database

Similar Questions

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

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

  • 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

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

  • 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>
    
  • 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>
    
  • Remove the clicked point of Listbox (single column)

    Hello

    It seems a lot of posts on clear lines of the programmatically multicolumn listbox but not the only column listboxes.

    Woth the help of Martins and GerdW, helped me build a subset of a ListBox with items clicked in a reference list

    Make a table of items clicked in a list

    . How it adds a feature to delete just in case rather than the deletion of the entire list and do it all over again.

    Thanks in advance.

    Have an array of strings to the "REF" enter in the list box and store it on a shift register. When you remove an item (for example, for an event), remove this item from the list (using the removal of the table) and write back to the property Ref of the listbox. A single-column list box works exactly the same way as a multicolumn listbox.

    (Excuse the broken links to properties - what happens when you create an excerpt)

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

  • Two foreign keys of a table in a single column

    Hi gurus

    I wonder that can we add two foreign keys of a table on a single column, I think the answer is, but what should be the reason behind this?

    Appreciate if someone there explain to me...

    Concerning

    Muzz

    Hello Muzz,

    Perhaps the example of human Chen reveals a design error.
    If a student has a 'teacher_id' "teacher" FK and FK for "emp" becaue each teacher is an EMP, I guess that the correct design would be to have only the FK of 'teacher' and to have another pointing to the 'emp' table in the 'teacher' tabe FK

    But we can imagine comical situations...
    CREATE TABLE PEOPLE (id NUMBER of KEY PRIMARY, name VARCHAR2 (20 CHAR),...);
    CREATE TABLE SCIENTIST (id people KEY PRIMARY NUMBER (id) REFERENCES, discipline VARCHAR2 (20 CHAR),...);
    CREATE TABLE POLICEMAN (id REFERENCES to KEY PRIMARY NUMBER (id), hire_date people DATE,...);

    First table = all.
    2nd: a subset of the first, with people having the profile of 'scientific '...
    3rd: a subset of the first, with people being a policeman.
    It might be people first table and in none of the 2nd and 3rd, 1st and 2nd, 1st and 3rd only or in the 3 tables.

    Then we can have a fourth table of 'something' referring to a person who must be a scientist and a police officer.

    Here is a sqlplus session illustrating; the last piece: I try inserting several lines in xxxx, only the last is accepted.

    SQL > CREATE TABLE PEOPLE (id NUMBER of the PRIMARY KEY, name VARCHAR2 (20 CHAR));
    Table created.

    SQL > CREATE TABLE SCIENTIST (people of REFERENCES of KEY PRIMARY NUMBER id (id), discipline VARCHAR2 (20 CHAR));
    Table created.

    SQL > CREATE TABLE POLICEMAN (people of REFERENCES of KEY PRIMARY NUMBER id (id), DATE hire_date);
    Table created.

    SQL > CREATE TABLE XXXX (id PRIMARY KEY NUMBER, people_id NUMBER, any other VARCHAR2 (30 CHAR));
    Table created.

    SQL > ALTER TABLE ADD CONSTRAiNT fk_xxsci FOREIGN KEY (people_id) scientific xxxx REFERENCES (id);
    Modified table.

    SQL > ALTER TABLE ADD CONSTRAiNT fk_xxpol FOREIGN KEY (people_id) police xxxx REFERENCES (id);
    Modified table.

    SQL > INSERT INTO person VALUES (100, 'John');
    1 line of creation.

    SQL > INSERT INTO person VALUES (120, 'Mary');
    1 line of creation.

    SQL > INSERT INTO person VALUES (103, 'Tom');
    1 line of creation.

    SQL > INSERT INTO person VALUES (123, "Bruno");
    1 line of creation.

    SQL > INSERT INTO VALUES of scientific (120, 'Chemistry');
    1 line of creation.

    SQL > INSERT INTO scientific VALUES (123, 'Mathematics');
    1 line of creation.

    SQL > INSERT INTO VALUES of policeman (103, DATE ' 2001-04-01');
    1 line of creation.

    SQL > INSERT INTO VALUES of policeman (123, DATE ' 1998-07-01');
    1 line of creation.

    SQL > INSERT INTO xxxx VALUES (1, 456, "nothing");
    ERROR on line 1:
    ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not found

    SQL > INSERT INTO xxxx VALUES (1, 100, "only to people");
    ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not found

    SQL > INSERT INTO xxxx VALUES (1, 120, "only the learned");
    ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not found

    SQL > INSERT INTO xxxx VALUES (1, 103, "only police officer");
    ORA-02291: integrity constraint (SYS. FK_XXSCI) violated - key parent not found

    SQL > INSERT INTO xxxx VALUES (1, 123, 'ok');
    1 line of creation.

    Best regards

    Bruno Vroman.

  • Selection of Pixel single column, then paste...

    Hello

    This might look like a very unusual request, but I was upset to find the answer.

    In a given photographic image, I would choose a single pixel in each row of pixels, running up and down in a columnof a pixel.  Then, I want to eliminate (Cup) nothing else on the Web with the exception of the one column of selected pixels. From there, I would take the pixel selected in each line and copy the pixel color on each line on the left and right of the pixel selected.

    The end result is that I have a series of horizontal lines of pixels height of one color (based on the color of the selected pixel) through the image of left and right.

    Looking at this picture:

    Select a single pixel on each line in a single column-

    xxxxxx XXXXXXS

    xxxxxx XXXXXXS

    xxxxxx XXXXXXS

    Remove/cut everything except the selected pixels in only one column-

    ...... S......

    ...... S......

    ...... S......

    Now, on each line, copy single pixel selected to the left and the right of the selection, to the extent of the canvas-

    SCOTTS SCOTT

    SCOTTS SCOTT

    SCOTTS SCOTT

    Interesting challenge or Easy-Peasey?

    Thank you!

    Easy. Use the brand single pixel tool to select a line of pixels. Cmd/Ctrl-J to copy pixels into a new layer. CTRL/cmd-click on the layer icon to select these pixels. CTRL/cmd-T to turn those pixels on the width of the image.

  • Object Table of XMLType vs single column of XMLType Table

    What are the differences between the XMLType table object and a table with a single column of XMLType?

    It's

    CREATE TABLE XMLType xml_table;

    and

    CREATE TABLE xml_table (xml_field XMLTYPE);

    That should be used and when? Both may be declared to be aware of schema.

    The main difference is that an XMLType object array allows the use of the XML DB Repository to store and retrieve XML content.
    The relationship between a resource and its content is maintained by a "pointer" (REF XMLType) line in the XMLType table:

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb03usg.htm#ADXDB4223
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb03usg.htm#BJFBDEJE

    Tables based on the patterns of XMLType (including the associated nested structure) can also be created automatically through recording scheme, which is very convenient when the pattern becomes complex.
    In addition, a registred schema-compliant documents that go into the repository automatically stored in the table by default (see the annotation xdb:defaultTable).
    We can also use ACLs to control access to specific rows in a table of object XMLType.

    This is not possible with XMLType columns in a relational table.

  • How concatinate values of column in a single column

    Hello

    Can someone tips n how to concatenate column values in a single column.

    I want the source of a particular procedure / trigger all_source table, but the select statement displays the text filed in several lines.

    Select * from all_source where name = "xyz";

    Is it possible that the result will be in a single line with the entire source code in a single column.


    Kind regards
    SY

    or may be

    SELECT name,
           LTRIM(MAX(SYS_CONNECT_BY_PATH(text,'-'))
           KEEP (DENSE_RANK LAST ORDER BY curr),'-') AS source_code
    FROM   (SELECT name,
              text,
                   ROW_NUMBER() OVER (PARTITION BY name ORDER BY text) AS curr,
                   ROW_NUMBER() OVER (PARTITION BY name ORDER BY text) -1 AS prev
            FROM   user_source)
    GROUP BY name
    CONNECT BY prev = PRIOR curr AND name = PRIOR name
    START WITH curr = 1
    /
    

    or may be

    SQL> select dbms_metadata.get_ddl('PROCEDURE','A_PROC') from dual;
    
    DBMS_METADATA.GET_DDL('PROCEDURE','A_PROC')
    --------------------------------------------------------------------------------
    
      CREATE OR REPLACE PROCEDURE "SCOTT"."A_PROC" (tablename varchar2,user_name var
    char2)
    as
    cursor c1 is select column_name from all_tab_columns where table_name=tablename
    and owner=user_name;
    a1 c1%rowtype;
    begin
    open c1;
    loop
    exit when c1%notfound;
    fetch c1 into a1;
    dbms_output.put_line(a1.column_name||',');
    end loop;
    close c1;
    
  • PanelBox and the single column Table

    Hi all

    I have a panelBox with a table T1 single column. I would like to add an array of columns more simple T2 right next to the first table T1.
    Jdev he added under the first table, but I want to be in the same line.

    Is this possible?


    Thank you
    Matthew

    Hi Matthew,

    How to add panelGroupLayout with a horizontal layout inside panelBox and put your tables inside the panelGroupLayout?

    Jean Lou

Maybe you are looking for

  • Security certificate is no longer valid after the upgrade to the latest FF.

    I've upgraded to the latest version of FF over the weekend and now I can't access a site that I had been accessing for the following error message:An error occurred during a connection to grdpmgr01.dmz.domainname.com:7799.The issuer certificate is no

  • Issue of Apple Mail - account does not exist

    There is no account in Mail, but the mail keeps asking for the password. What is happening on my new Macbook 12 "who migrated via Time Machine of my very old MacBook Pro. If the account in question does not exist, how can I find and get rid of it? Th

  • HP envy 17 dvdram gu70n at startup

    I get the following on the driver status: Windows cannot start this hardware device because its information of configuration (in the registry) is incomplete or damaged. (Code 19) I tried: 1. Uninstall and scan for hardware changes 2. Uninstall and re

  • need driver for NVIDIA

    need driver for ms IE 8 & tv

  • How can I disable the zoom to screen in windows 7 to my mouse pointer

    Original title: how to adjust the zoom level Zoom Windows How can I disable the zoom to screen in windows 7 to my mouse pointer its driving me crazy. Whenever I move the mouse around the page as it zooms in and out.