convert the column values to a single line...

I have to return the column values to a single line separated by commas.
If the nulls in the column just ignore without a comma.
Here is one for example. There are three values and two NULL values in the table
SQL> select ID from temp_fa;
ID
-----

         1
         2

         3

         5

6 rows selected.


I am expecting an output as 1,2,3,5
Help, please

There is always more than one title in the Oracle world ;)
You can use the TRIM, for example (same configuration as your example):

hoek&XE>  create table t as select level col  from dual connect by level <= 6;

Tabel is aangemaakt.

hoek&XE> update t set col = null where col in (1,3,5);

3 rijen zijn bijgewerkt.

hoek&XE> select * from t;

       COL
----------

         2

         4

         6

6 rijen zijn geselecteerd.

hoek&XE> select ltrim(sys_connect_by_path(col, ','), ',') output
  2  from  ( select col
  3          ,      row_number() over (order by col) rn
  4          from   t
  5        )
  6  where connect_by_isleaf=1
  7  start with rn=1
  8  connect by rn = prior rn+1;

OUTPUT
-------------------------------------------------------------------------------------------------------------
2,4,6,,,

1 rij is geselecteerd.

hoek&XE> select trim ( both ',' from sys_connect_by_path(col, ',')) output
  2  from  ( select col
  3          ,      row_number() over (order by col) rn
  4          from   t
  5        )
  6  where connect_by_isleaf=1
  7  start with rn=1
  8  connect by rn = prior rn+1;

OUTPUT
-------------------------------------------------------------------------------------------------------------
2,4,6

1 rij is geselecteerd.

Tags: Database

Similar Questions

  • 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

  • All the dimension values must be single line values

    I created a Simple hierarchy with the following levels:

    Category
    Subcategory
    Agenda

    The mapping of the hierarchy above is based on a table where the column list are as follows:

    ITEM_KEY
    NOM_ELEMENT
    BRAND_KEY
    BRAND_NAME
    CATEGORY_KEY
    CATEGORY_NAME
    SUBCATEGORY_KEY
    SUBCATEGORY_NAME


    Item_key is the primary key for this table and nom_element is also unique.

    When I maintain this dimension, the following error occurs:


    An error occurred on the server
    Class of error: failure of the Express
    Server error descriptions:
    INI: Error creating a generic Manager definition to < BuildProcess > TxsOqConnection::generic
    INI: XOQ-01600: OLAP DML error "all dimension values must be single line values." while executing DML 'SYS. AWXML! R11_COMPILE_ATTRIBUTES('ITEM.) DIMENSION') ', generic for TxsOqStdFormCommand::execute '.

    at oracle.olapi.data.source.DataProvider.callGeneric (unknown Source)
    at oracle.olapi.data.source.DataProvider.callGeneric (unknown Source)
    at oracle.olapi.data.source.DataProvider.executeBuild (unknown Source)
    to oracle.olap.awm.wizard.awbuild.UBuildWizardHelper$ 1.construct (unknown Source)
    to oracle.olap.awm.ui.SwingWorker$ 2.run (unknown Source)
    at java.lang.Thread.run(Thread.java:595)

    The essential error is "all the dimension values must be unique row values", which means that the server tries to create a dimension of AW member containing a newline character. The error occurs under the SYS. AWXML! Procedure R11_COMPILE_ATTRIBUTES, which is where the attributes are indexed (i.e. transformed into dimension members). If my guess is that one of your attributes (likely mapped to a column _NAME) contains a new line.   The solution is to disable the indexing for that attribute.   In terms of AWM you must make sure the following boxes are not activated in the "Général" pane

  • Create the views level attribute columns
  • Index

  • All dimension values must be single line values

    Hi all

    I have a dimension long_description attribute mapped to a column of text that contains a character "/ n". When I try to load dimension I get following error.


    An error occurred on the server
    Class of error: failure of the Express
    Server error descriptions:
    INI: error creating a generic Manager definition to < BuildProcess > TxsOqConnection::generic
    INI: XOQ-01600: OLAP DML error "ORA-34052: all the dimension values must be single line values." while executing DML 'SYS. AWXML! R11_COMPILE_ATTRIBUTES('TEST.) DIMENSION') ', generic for TxsOqStdFormCommand::execute '.

    If I delete the mapping between my column of text in the description attribute long size loads very well.

    It was happening because my text column contains several lines? text seems valid for reporting purposes (I mean having several lines)

    Thank you
    Dietsch.

    Analytic workspace dimensions do not support dimension members that contain new lines. This assumption is so integrated in language OLAP DML that it is difficult to see how it could ever be changed. Therefore, you cannot map a level (or hierarchy) key to a column that contains values to the new lines. But in your case you map an attribute, not a level key, so the error message is confusing. The problem is that your long description attribute is "indexed", which means that it is implemented using a DIMENSION and a RELATIONSHIP rather than a VARIABLE. To illustrate, I created a dimension named TEST with two levels, A and B, and one attribute, LONG_DESCRIPTION. The page of an attribute in AWM has two check boxes 'Create columns in views level attribute' and 'Index' that control how the attribute is being implemented.

    This is what is created in the AW if both are false.

    ->listnames like '%TEST%LONG%'
       1 VARIABLE
       ---------------------
       TEST_LONG_DESCRIPTION
    

    This is what is created if "Index" is checked.

    ->listnames like '%TEST%LONG%'
       1 DIMENSION                    1 VARIABLE
       ----------------------------   ----------------------------
       TEST_LONG_DESCRIPTION_INDEX    TEST_LONG_DESCRIPTION_STORED
    
       1 RELATION
       ----------------------------
       TEST_LONG_DESCRIPTION
    

    And here's what you get if you check "create columns for the level attribute of views."

    ->listnames like 'TEST%LONG%'
       2 DIMENSIONs                     3 VARIABLEs
       ------------------------------   ------------------------------
       TEST_A_LONG_DESCRIPTION_INDEX    TEST_A_LONG_DESCRIPTION_STORED
       TEST_B_LONG_DESCRIPTION_INDEX    TEST_B_LONG_DESCRIPTION_STORED
                                        TEST_LONG_DESCRIPTION
    
       6 RELATIONs
       ------------------------------
       TEST_A_LONG_DESCRIPTION
       TEST_A_LONG_DESCRIPTION_HIER_U
       TEST_A_LONG_DESCRIPTION_UNIQUE
       TEST_B_LONG_DESCRIPTION
       TEST_B_LONG_DESCRIPTION_HIER_U
       TEST_B_LONG_DESCRIPTION_UNIQUE
    

    The thing to note is that if you check one of these boxes, then your attribute is implemented by using a dimension of AW and AW relationship. This gives a good performance, but imposes the limitation that your attribute values cannot contain newlines. The obvious solution is to uncheck both boxes so that your attribute is implemented as a VARIABLE. If you absolutely have indexed attributes, so I guess you can use the SQL REPLACE function to change the new lines in escaped to the mapping layer

    GLOBAL > select REPLACE('a
      2  b', '
      3  ',
      4  '\n')
      5* from dual
    /
    
    REPL
    ----
    a\nb
    
    GLOBAL > select REPLACE('a\nb', '\n','
      2  ')
      3* from dual
    /
    
    REP
    ---
    a
    b
    

    You must convert the escape sequence in a new line endangered.

  • two column values in a single column

    Hi guys,.

    I have a requirement that i want to be viewing the two column values in a single as column... values year & product will be exposed in a unique column values

    Kind regards

    Sree

    Karthickumar Pillaiyarsamy yours is a database, in OBIEE is similar with some limitations...

    Sree! you have 2 ways to do this: by using the CONCAT function or the | operator, examples here are 2 concatenating year, a space and production:

    "Time". "" T05 annually name | ' ' || ' 'Products ' '. Product P1.

    CONCAT ("Time". "T05 per year of name', CONCAT (" ","Products".)" P1 product"))

    CONCAT in OBIEE accept only 2 params, so you if want to add a space between the 2 items, you must nest your function call.

    In case your year column is a number, you can convert it to a string using CAST ("your column" as VARCHAR (10)).

  • convert the column to a string name

    pls help me.

    I need to know how can I convert the column to a string name because I can not insert the column name into my table.


    for matrix (SELECT nom_de_colonne
    OF all_col_comments@myDBLink
    WHERE UPPER (trim (table_name)) = "ROLEMATRIX")
    loop
    INSERT INTO myTABLE (myColumn)
    VALUES (matrix.column_name);
    end loop;


    my error:
    ORA-00984: column not allowed here

    which line you are confronted with error, because I've also tested this, his work on my side!

  • How to change the background color of a single line

    Hi, OTN,.

    I use JDeveloper with ADF faces 11.1.1.2 in the view layer. My question is how to change the background color of a single line in af:table?.

    Hi idir Mitra
    You can use EL to bind column for example inlineStyle (#{row.id == null?' background-color: rgb (255,214,165);':'background-color:red'})})

    Cordially Abhilash.S

  • How to convert the binary value to a binary string in labview?

    Hi all

    I need to convert the binary value to a binary string. We have decimal or hexadecimal or octal number to decimal string, hexadecimal and octal string

    Hi pgm, use the function 'Format to a string. See the attached example. "%b" is the binary number in number in string format specifier.

  • Compare the column values for multiple lines

    I am new to oracle and I have a requirement to compare the values of column across multiple lines.  If all column values are the same, I want to display that value, if the columns are not the same, I need to display 'no match' as value.   I need id to group values and display a status value based on the above logic.   Can anyone offer assistance with dispalying the result expected below?

    Sample

    Table

    State ID

    1         S

    2         L

    1         S

    2          S

    expected results

    State ID

    1         S

    2 no match


    Hello

    That's what you asked for:

    SELECT id

    CASE

    WHEN COUNT (DISTINCT status) > 1

    THEN "no match."

    For ANOTHER MIN (status)

    The END as status

    T

    GROUP BY id

    ;

    Want that if each State ID is NULL?  The CASE expression above returns NULL in this situation.

  • Get the cumulative values in a single column based on another column in reports

    Hi all

    I have a requirement to get cumulative values based on another column.
    I 'Sales rep name' in the first column.
    Correspondent "Values of the invoice line" in the second column.
    Want to have cumulative of all the values for each sales invoice line.
    Then apply rank and display the top 10 sales reps based on invoice lines.
    Since there is no rank option in the PivotTable, I do this in the report table.

    Looking for the best entries...

    Thanks in advance...

    Try below
    2nd column: "name of Sales rep.
    column 2: SUM ("invoice line values ' BY 'Name of Sales rep'") and sort this field desc.
    3rd column: fx RANK (SUM ("invoice line values" BY "Sales rep name")), to hide this column, so that you don't confuse your users.

    and put the filter on the 3rd column below 5

    I hope this works for you

  • How to convert the column lines

    I need to convert my output lines of sql for the column as a pivot to 11g

    Please give me the example of this

    check out this link

    http://nimishgarg.blogspot.com/2010/06/Oracle-pivot-data-rows-to-columns.html

    request for 10g would be

    Select *.
    (select job,
    Sum (decode(DEPTNO,10,SAL)) dept10,
    Sum (decode(DEPTNO,20,SAL)) dept20,
    Sum (decode(DEPTNO,30,SAL)) dept30,
    Sum (decode(DEPTNO,40,SAL)) dept40
    from scott.emp
    Working Group)
    order by 1;

  • Update the column values with the new user who has changed the data in the current line

    I have a table, the following structure.

    CREATE TABLE FILTERCALENDAR1
    (DATE OF THE "C_DATE',
    NUMBER (1,0) 'DAY_OF_WEEK ',.
    NUMBER (1.0) "WEEK_WINDOW."
    NUMBER (1.0) "MONTH_WINDOW."
    NUMBER (1.0) "YEAR_WINDOW."
    NUMBER (1.0) "DATE_YEAR_WINDOW."
    NUMBER (1.0) "ONCE_WINDOW."
    VARCHAR2 (25 BYTE) "USERNAME."
    "LASTUPDATED" DATE
    );

    Problem:
    If a user changes the value of one of the columns I want to write his name to user and sysdate in the 'USERNAME' and LASTUPDATED' columns.

    * Tried: *.
    I tried an update trigger for this problem, but I get an error table mutation.

    The one you suggest how can I achieve this.

    Concerning

    Use BEFORE the UPDATE trigger

    CREATE OR REPLACE TRIGGER myTrigger
    before UPDATE ON FILTERCALENDAR1 FOR EACH ROW
    BEGIN
    :new.USERNAME := user;
    :new.LASTUPDATED := sysdate;
    END;
    
  • Select the column values in the collection

    Greetings,

    I want to select column values from the collection (plsql tables or table), as the following code, would it be possible
    Here tt is any collection



    Select emp_no, name, date of birth, sal tt (1), tt (2), tt (3), tt (4) emp; -single line query

    Select name, Department of justice, strength and dep_no in tt (5), tt (6), tt (7), tt (8) EMP; -single line query


    Version
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production

    Thanks in advance

    Not sure about your business needs. But technically you can do.

    declare
       type tbl is table of number;
       lemp tbl := tbl();
    begin
       lemp.extend;
       lemp.extend;
       lemp.extend;
    
       select empno
            , mgr
            , sal
         into lemp(1)
            , lemp(2)
            , lemp(3)
         from emp
        where empno = 7369;
    
       for i in 1..lemp.count
       loop
         dbms_output.put_line(to_char(lemp(i)));
      end loop;
    end;   
    
  • How to convert the Editfield value chain

    Greetings

    Please help me to convert the editfield in sting.

    with the help of toString (), it does not convert it to a string.

    Help, please

    concerning

    Anthony singh

    arkadyz is located...

    but you must put this line in an event thread... because you enter the value in an editfield dynamically (at runtime) he must go and look after that the value has been added...

    As you can use a button... When you click on it, then the value is extracted from the help:

    final String text = SmsField.getText ();

    and your dialog box appears...

  • divide the value in the column value

    Hi all

    I have an EMP table with column (NAME varchar2 (100)). It has a full name with name value "«MIDDLE_NAME"»
    It should always has 3 words value separated by single spaces.

    Value of the sample: FRANKLIN ROOSEVELT OBAMA


    I want to create a view EMP2_VW that contains a split each distinct names as MIDDLE_NAME, LAST_NAME, FIRST_NAME


    How can I do this?


    Thank you very much
    SQL> with t as (
      2  select 'FRANKLIN ROOSEVELT OBAMA' fullname from dual
      3  )
      4  --
      5  -- actual query:
      6  --
      7  select fullname
      8  ,      substr( fullname
      9               , 1
     10               , instr(fullname, chr(32))-1
     11               ) first_name
     12  ,      substr( fullname
     13               , instr(fullname, chr(32), 1, 1)+1
     14               , instr(fullname, chr(32), 1, 2)-1 - instr(fullname, chr(32), 1, 1)
     15               ) middle_name
     16  ,      substr( fullname
     17               , instr(fullname, chr(32), 1, 2)+1
     18               ) last_name
     19  from   t;
    
    FULLNAME                 FIRST_NAME               MIDDLE_NAME              LAST_NAME
    ------------------------ ------------------------ ------------------------ -------------
    FRANKLIN ROOSEVELT OBAMA FRANKLIN                 ROOSEVELT                OBAMA
    
    1 row selected.
    

Maybe you are looking for