Comma separated output i need

Hi, am new to oracle pls help me with the below query.....
i have below table
empname deptno
ssss 10
aaaa 10
www 10
qqqq 20
eeee 20
i need a output like this
deptno empname
10 ssss ,aaaa ,www
20 qqqq ,eeee
thanks in advance

In 11gR2:
SQL> select deptno, listagg(ename, ',') within group (order by ename) enames from emp
group by deptno
         DEPTNO ENAMES                                 
             10 CLARK,KING,MILLER                      
             20 ADAMS,FORD,JONES,SCOTT,SMITH           
             30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD   
3 rows selected.

Similar Messages

  • Comma separated output into columns

    Hi,
    I've the following Query :
    select ParameterValue
     FROM Event.vEvent 
     join event.vEventParameter on event.vEventParameter.EventOriginId=event.vEvent.EventOriginId
     where EventNumber=0
    which gives the following output in a single column:
    VSSDATA_FS,171423,106013,142420,11,248433,Wed Jun  4 03:40:58 EDT 2014
    DATAGRP_FS,2302724,1074283,2208370,39,3282653,Wed Jun  4 07:54:26 EDT 2014
    DATAPUB_FS,100837,5998,36688,49,42686,Wed Jun  4 03:04:42 EDT 2014
    SHT_APT_FS,1008350,651,3906,84,4557,Mon Jun  2 03:12:35 EDT 2014
    SHT_GER_FS,806699,809987,747788,52,1557775,Thu Jun  5 03:55:33 EDT 2014
    DATAGRP1_FS,151256,24805,120496,33,145301,Tue Jun  3 05:11:31 EDT 2014
    I need to separate the above output in different columns using separators as ',' (comma).
    Please help me in achieving this as I'm a newbie in SQL.

    pass it through a parameter
    DECLARE @p varchar(max) = 'VSSDATA_FS,171423,106013,142420,11,248433,Wed Jun  4 03:40:58 EDT 2014
    DATAGRP_FS,2302724,1074283,2208370,39,3282653,Wed Jun  4 07:54:26 EDT 2014
    DATAPUB_FS,100837,5998,36688,49,42686,Wed Jun  4 03:04:42 EDT 2014
    SHT_APT_FS,1008350,651,3906,84,4557,Mon Jun  2 03:12:35 EDT 2014
    SHT_GER_FS,806699,809987,747788,52,1557775,Thu Jun  5 03:55:33 EDT 2014
    DATAGRP1_FS,151256,24805,120496,33,145301,Tue Jun  3 05:11:31 EDT 2014'
    SELECT Val
    FROM dbo.ParseValues(@p,',')
    ParseValues can be found here
    http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Comma separated output using report builder

    Hi Experts,
    I am working with EBS 11.5.10, database 9i, and report builder 6i. I have a XML Publisher report, with output type EXCEL, which is working fine. But if i get huge data like 1million, 2million, it's not able accommodate the output in EXCEL. Since it's EXCEL 2003, it can't handle data more than it's capacity(i think 60,000 rows).
    So we thought, if we can generate the output in CSV file with comma separte, then we can open the file in EXCEL 2007. Could somebody help me how to generate the CSV output using report builder 6i.
    or is there any work around to our problem, kindly help me, it's urgent.

    Hi,
    Not sure if report builder can be made to generate csv output.
    But you can create a PLSQL Report. Just use the query of Report Builder and write a Plsql procedure based on this query
    -Idris

  • Comma separated output

    4.we have employee table with Empname empno and deptnum
    tabel name:emp
    deptno name
    10 A
    10 B
    10 C
    i need output like this
    deptno name
    10 A,B,C

    Hi,
    See this link
    http://www.dba-oracle.com/t_converting_rows_columns.htm
    There I did find query what should do what you are looking
    select
       deptno,
       rtrim (xmlagg (xmlelement (e, ename || ',')).extract ('//text()'), ',') enames
    from
       emp
    group by
       deptno
    ;Regards,
    Jari

  • How to read a comma separated file in web dynpro for java?

    Hi,
    I am new to web dynpro for java, i am trying to develop an application where i am uploading file which is a comma separated file i need to read the content of it and then call an rfc  pass those values to it. i have created the ui for the afforesaid.
    How do i read the content and call the RFC please help
    Thanks

    Hi Anumeha,
    Perhaps your question can be answered in the Web Dynpro Java .
    Thank you.
    Regards,
       Jan

  • Need to Convert Comma separated data in a column into individual rows from

    Hi,
    I need to Convert Comma separated data in a column into individual rows from a table.
    Eg: JOB1 SMITH,ALLEN,WARD,JONES
    OUTPUT required ;-
    JOB1 SMITH
    JOB1 ALLEN
    JOB1 WARD
    JOB1 JONES
    Got a solution using Oracle provided regexp_substr function, which comes handy for this scenario.
    But I need to use a database independent solution
    Thanks in advance for your valuable inputs.
    George

    Go for ETL solution. There are couple of ways to implement.
    If helps mark

  • Need to have comma separated format

    Hi all
    I have developed a code in which is a file is stored in application server.  The text in the file is continous without any space.  I need to have text in comma separated format.
    Plz help. Its urgent.
    Regrds
    Mona

    Hi,
    Following report tis the sample report for your requirement.
    *Reading and Writing a text file from and to the application server*
    * sy-subrc = 0              Record read from file
    * sy-subrc = 4              End of file reached
    data:  w_dataset1(27) value '/var/textfile.txt',
              w_dataset2(27)  value '/var/outfile.txt'.
    data:begin of itab1 occurs 0,         "Text file format
               matnr(18),      "MATERIAL NUMBER
               bwkrs(4),       "PLANT
           end of itab1.
    *Uploading of text file from Application server.
    open dataset w_dataset1 for input in text mode.
           do.
                  if sy-subrc <> 0.
                      exit.
                  endif.
                  read dataset w_dataset1 into itab1.
                 append itab1.
                 clear itab1.
            enddo.
    close dataset w_dataset1.
    *Downloading of text file to Application server.
    open dataset w_dataset2 for output in text mode.
    loop at itable.
        transfer itable to w_dataset2.
    endloop.
    close dataset w_dataset2.
    Thanks,
    Sankar M

  • Enable comma separated values (CSV) output

    I am trying to figure out how to (Enable comma separated values (CSV) output ) for a report. Do you have an example or info on how to do that?

    Can you provide an example on how you completed the setup? I am in the same boat but can't find an example to this subject

  • Result may contain single string or comma separated need to split into rows

    Hi, All... I've searched through the forums and found plenty on splitting comma separated into rows; though I'm struggling applying it to my situation. I have data that looks like the below where I need to split a value into multiple rows if it should be but the same field in the table may also contain a string that should not be separated (indicated by the "Array" field being 0 or 1)...
    WITH t AS
    (SELECT 1 as array, '"Banana", "Apple", "Pear"' as str FROM dual union all
    SELECT 0, 'Fruit is delicious' FROM dual union all
    SELECT 0, 'So are vegetables' FROM dual union all
    SELECT 1, '"Bean", "Carrot", "Broccoli"' FROM dual union all
    SELECT 1, '"Apple", "Banana"' FROM dual)I've looked through many of the connect_by posts on the forum and I haven't come across one that splits a field if it should be but doesn't if it should not be... may have missed it because there are plenty of these requests on the forum!
    If you're feeling even more ambitious - the ultimate goal is to count the number of times a particular answer appears in an array - so notice the last portion of the data contains "Apple", "Banana"... the result would show:
    RESULT
    Banana             2
    Apple              2
    Pear               1
    Bean               1
    Carrot             1
    Broccoli           1
    Fruit is delicious
    So are vegetablesI can always sort them later based on other fields in the table - but the result above would be my ultimate goal!
    Any help is always appreciated. Thanks! 11g

    Hi,
    The examples you found should work for you. Just use a CASE expression to determine if str needs to be split or not, by looking at array.
    Here's one way:
    WITH     got_part_cnt     AS
         SELECT     array, str
         ,     CASE
                  WHEN  array = 0
                  THEN  1
    --              ELSE  1 + REGEXP_COUNT (str, '", "')     -- See note below
                  ELSE  1 + ( ( LENGTH (str)
                                  - LENGTH (REPLACE (str, '", "'))
                         / 4
              END          AS part_cnt
         FROM    t
    ,     cntr     AS
         SELECT  LEVEL     AS n
         FROM     (
                  SELECT  MAX (part_cnt)     AS max_part_cnt
                  FROM    got_part_cnt
         CONNECT BY     LEVEL     <= max_part_cnt
    ,     got_sub_str          AS
         SELECT     CASE
                  WHEN  p.array = 0
                  THEN  p.str
                  ELSE  REGEXP_SUBSTR ( p.str
                                   , '[^"]+'
                             , 1
                             , (2 * c.n) - 1
              END     AS sub_str
         FROM     got_part_cnt  p
         JOIN     cntr           c  ON  c.n <= p.part_cnt
    SELECT       sub_str
    ,       COUNT (*)     AS cnt
    FROM       got_sub_str
    GROUP BY  sub_str
    ORDER BY  cnt          DESC
    ,            sub_str
    {code}
    The only database at hand right now is Oracle 10.2, which doesn't have REGEXP_COUNT.  I had to use a complicated way of counting how many times '", "' occurs in str in order to test this in Oracle 10.  Since you have Oracle 11, you can un-comment the line that uses REGEXP_COUNT in the first CASE expression, and remove the alternate ELSE clause (that is, the next 5 lines, up to END).
    To make sure that this query is really paying attention to array, I added this row to the sample data:
    {code}
    SELECT 0, '"Bean", "Carrot", "Broccoli"' FROM dual union all
    {code}
    Even though str looks just like a delimited list, array=0 tells the query not to split it, so it produces these results:
    {code}
    SUB_STR                               CNT
    Apple                                   2
    Banana                                  2
    "Bean", "Carrot", "Broccoli"            1
    Bean                                    1
    Broccoli                                1
    Carrot                                  1
    Fruit is delicious                      1
    Pear                                    1
    So are vegetables                       1
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to generate oracle report output in a comma separated format in reports

    Pls any one can help in generation of oracle report in comma separated format in reports 10g.....
    thanks,
    prasad.
    1,Chennai,Nokiasiemen,Convent junction,5535

    Use desformat=delimited.
    http://download.oracle.com/docs/cd/E15523_01/bi.1111/b32122/orbr_howto007.htm#i1040102

  • File need to be read in different formats( Tab formatted, commas separated)

    Hi All,
    I am reading an input text file which can be in any of the format like tab formatted, commas separated or fixed format. How can i write a code to make it work for all these file format other than writing separately for the above three cases. Kindly suggest.
    Thanks,
    Neslin.

    As far as seperators are concerned you may read entire file to stirng table, then identify separator (i.e. if you find  tab mark, you assume it is tab separated; if you find ";" mark you assume this is a column separator). Use SEARCH or FIND statement and then (after having the separator) loop at string table and split each entry at this separator. If none of the above was find (no separator or fixed one) split according to given fixed format.

  • Comma separated format is required

    Hi all
    this is the code which i have written:
    OPEN DATASET g_ufile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
       LOOP AT t_file WHERE werks = t_file1-werks.
        MOVE : gc_kaganplntcode TO t_file-fieldname1,
               gc_productcode TO t_file-fieldname2,
               gc_qtyavailable TO t_file-fieldname3.
              CONCATENATE t_file-fieldname1
                          t_file-fieldname2
                          t_file-fieldname3
                       INTO gv_itemdet1 separated by ','.
       ENDLOOP.
         transfer gv_itemdet1 to g_ufile.
        loop at t_file into t_file1.
        condense t_file1 no-gaps.
        transfer t_file1 to g_ufile.
        append t_file1.
        clear t_file1.
        clear gv_itemdet.
        endloop.
    in t_file1 data is coming in continous manner. i need to have comma separated data. ie each field shud be separated by ','.
    can anybody tell me logic for it.
    very urgent.
    regrd
    Mona
    Edited by: Alvaro Tejada Galindo on Apr 14, 2008 1:03 PM

    Try it this way mona
    Declare a fiel-symbol type any and an string to tranfer the contents.
    loop at t_file into t_file1.
    clear string.
    condense t_file1 no-gaps.
    do.
    assign component sy-index of structure t_file1 to <fs>.
    if sy-subrc ne 0.
    exit.
    endif.
    concatenate string <fs> ',' into string.
    enddo.
    transfer string to g_ufile.
    append t_file1.
    clear t_file1.
    clear gv_itemdet.
    endloop.

  • Powershell ADODB Recordset getstring comma separated

    I am having problems with the getstring method of the Adodb.recordset object in Powershell 
    I wish to output a comma-separated string of a persisted recordset. I am not entirely sure the correct syntax for the getstring method 
    when I write the following
    $objRecordset.Getstring(,,",",,)
    I get the following error
    Missing ')' in method call.
    At :line:1 char:25
    + $objRecordset.Getstring(, <<<< ,",",,)
    The full code is below
    $adOpenStatic = 3
    $adLockOptimistic = 3
    $objRecordset = New-Object -comobject ADODB.Recordset
    ## where Modeldata.rs is recordset save to ADTG file
    $objRecordset.Open("Modeldata.rs" , "Provider=MSPersist",$adOpenStatic,$adLockOptimistic)$objRecordset.MoveFirst()
    ## outputs a tab delimited string by default
    $objRecordset.Getstring()
    ## output a comma delimited string
    $objRecordset.Getstring(,,",",,)
    ## returns the following error
    ##Missing ')' in method call.
    ##At :line:1 char:25
    ##+ $objRecordset.Getstring(, <<<< ,",",,)
    $objRecordset.Close()
    Can you please help?
    If this is not possible, is there a suitable workaround? 

    Thanks, jrv. That set me on the right track. I discovered also that I needed to enter a value for the second parameter (NumRows)
    as well. To return all records, I need to enter -1. 
    $objRecordset.Getstring(2,-1,",")

  • SQL - Multiple Fetch into Single Column with Comma Separator

    Hello Experts,
    Good Day to all...
    I need your help on following scenarios. The below query returns set of titleID strings. Instead of printing them one below the other as query output, I want the output to be in batch of 25 values.i.e each row should have 25 values separated by comma. i.e If there are 100 titles satisfying the output, then there should be only four rows with and each row having 25 titles in comma separated manner.
    SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);I tried with the PL/SQL block; whereas it is printing all the values continously :(
    I need to stop with 25 values and display.
    If its possible with SQL block alone; then it would be of great help
    DECLARE
       v_str   VARCHAR2 (32767)  := NULL;
       CURSOR c1
       IS
         SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);
    BEGIN
       FOR i IN c1
       LOOP
          v_str := v_str || ',' || i.title_id;
       END LOOP;
       v_str := SUBSTR (v_str, 2);
       DBMS_OUTPUT.put_line (v_str);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line ('Error-->' || SQLERRM);
    END;Thanks...

    You can use CEIL
    Sample code
    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(val,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
            SELECT
                val,
                nt,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val)    AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) -1 AS prev
            FROM
                    SELECT
                        level                          AS val,
                        ceil(rownum/3)  as nt /* Grouped in batches of 3 */
                    FROM
                        dual
                        CONNECT BY level <= 10
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;
            NT CONCAT_VAL
             1 1,2,3
             2 4,5,6
             3 7,8,9
             4 10Your code
    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(title_id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
            SELECT
                title_id,
                nt,
                ROW_NUMBER () OVER (PARTITion BY nt ORDER BY title_id)   AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY title_id) -1 AS prev
            FROM
                    SELECT
                        title_id,
                        ceil(rownum/25) AS nt /* Grouped in batches of 25 */
                    FROM
                        pack_relation tdpr
                    JOIN annotation fa
                    ON
                        tdpr.package_id = fa.package_id
                    GROUP BY
                        title_id,
                        fa.package_id
                    HAVING
                        COUNT (fa.package_id) < 500
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;

  • Comparing 2 comma separated value strings

    Hi
    I've the following requirement where i need to comapre 2 strings having comma separated values.
    declare
    v_Str1 varchar2(100) ;
    v_str2 varchar2(100);
    begin
    v_str1 := '123,234,456' ;
    v_str2 := '123,234';
    /*  *I need to write a logic to compare the above 2 strings
    Could you please give me  hint to achieve this*  */Thanks
    Edited by: smile on Mar 13, 2012 8:20 PM

    Try this
    declare
    v_Str1 varchar2(100) ;
    v_str2 varchar2(100);
    begin
    v_str1 := '123,234,456,4364' ;
    v_str2 := '123,234';
    For cur_rec in (
      select REGEXP_SUBSTR (v_str1, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str1,',')+1
      MINUS
      select REGEXP_SUBSTR (v_str2, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str2,',')+1) loop
      DBMS_OUTPUT.PUT_LINE(cur_rec.output);
    End loop;
    End;
    4364
    456
    PL/SQL procedure successfully completedAnother format
    declare
    v_Str1 varchar2(100) ;
    v_str2 varchar2(100);
    v_Str3 varchar2(100);
    begin
    v_Str1 := '600,100,500,200,300,400' ;
    v_Str2 :='100,200';
    For cur_rec in (
      select REGEXP_SUBSTR (v_str1, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str1,',')+1
      MINUS
      select REGEXP_SUBSTR (v_str2, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str2,',')+1) loop
      v_Str3:=v_Str3||','||cur_rec.output;
    End loop;
      v_Str3:=LTRIM(RTRIM(v_Str3,','),',');
      DBMS_OUTPUT.PUT_LINE(v_Str3);
    End;
    300,400,500,600
    PL/SQL procedure successfully completedEdited by: Lokanath Giri on १४ मार्च, २०१२ १:३३ अपराह्न

Maybe you are looking for

  • Assets purchasing without material master

    Hello Gurus The task is to configure assets procurement without using material masters. The free-text PO will be created and during goods receipt (MIGO) the cost of goods should be written off from Internal Order and immediately added to fixed asset

  • Any recommendation for to continue ?

    I was working in Oracle Forms, but now I decided to learn. I am study Java for the first part (Getting started) but there are more chapter but, I like to make application like account system. I was thinking to junk to java Swing for to continue study

  • Troubles using external speakers

    My daughter's Ipod works with her headphones but has just stopped working with her external speaker system (Sonic Impact I-Fusion). We purchased another speaker system thinking that was the problem, but it didn't work either. Has anyone else encounte

  • When i upgraded to itunes 10.4 the install freezes during intallation

    This first happened when i was prompted to upgrade to the newest version of itunes, when following the promts on screen the install of itunes freezes.There is no error code or warning comes up on my screen, it just freezes during the installation. it

  • Named query problem, [TOPLINK-6008] error

    I created a simple table in database (one column, two rows). I created java class and Data Control and dragged the Data Control onto JSP page. Data were shown ok. Then I tried to create named query (simple SELECT MyCol FROM FROM MyTable). This time t