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

Similar Messages

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

  • 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

  • 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

  • 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

  • Obtaining comma-separated list of text values associated with bitwise flag column

    In the table msdb.dbo.sysjobsteps, there is a [flags] column, which is a bit array with the following possible values:
    0: Overwrite output file
    2: Append to output file
    4: Write Transact-SQL job step output to step history
    8: Write log to table (overwrite existing history)
    16: Write log to table (append to existing history)
    32: Include step output in history
    64: Create a Windows event to use as a signal for the Cmd jobstep to abort
    I want to display a comma-separated list of the text values for a row. For example, if [flags] = 12, I want to display 'Write Transact-SQL job step output to step history, Write log to table (overwrite existing history)'.
    What is the most efficient way to accomplish this?

    Here is a query that gives the pattern:
    DECLARE @val int = 43
    ;WITH numbers AS (
       SELECT power(2, n) AS exp2 FROM (VALUES(0), (1), (2), (3), (4), (5), (6)) AS n(n)
    ), list(list) AS (
       SELECT
         (SELECT CASE WHEN exp2 = 1  THEN 'First flag'
                      WHEN exp2 = 2  THEN 'Flag 2'
                      WHEN exp2 = 4  THEN 'Third flag'
                      WHEN exp2 = 8  THEN 'IV Flag'
                      WHEN exp2 = 16 THEN 'Flag #5'
                      WHEN exp2 = 32 THEN 'Another flag'
                      WHEN exp2 = 64 THEN 'My lucky flag'
                 END + ', '
          FROM   numbers
          WHERE  exp2 & @val = exp2
          ORDER BY exp2
          FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
    SELECT substring(list, 1, len(list) - 1)
    FROM   list
    Here I'm creating the numbers on the fly, but it is better to have a table of numbers in your database. It can be used in many places, see here for a short discussion:
    http://www.sommarskog.se/arrays-in-sql-2005.html#numbersasconcept
    (Only read down to the next header.)
    For FOR XML PATH thing is the somewhat obscure way we create concatenated lists. There is not really any using trying to explain how it works; it just works. The one thing to keep in mind is that it adds an extra comma at the end and the final query strips
    it off.
    This query does not handle that 0 has a special meaning - that is left as an exercise to the reader.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SSRS Report : Comma Separated Hyperlinks

    Hello,
    I want to display Comma Separated Hyperlinks in SSRS Report. I am not sure what should I change here to get this working.
    Below is the flow of data.
    1. Extracting value from the SharePoint List using SSIS Package Script component and filling data in SQL Table.
    I have used this Table and created below view to stuff all these three links together.
    SELECT ID, STUFF
    ((SELECT ', ' + BCM.BCMProgramDocument
    FROM BCMProgramDocumentation BCM
    WHERE BCM.Risk = R.ID FOR XML PATH('')), 1, 1, '') AS BCMDoc
    FROM Risk R
    which gives me below output, not sure why.
    "<a href='http://yahoo.com'>YAHOO</a>", "<a href='http://gmail.com'>GMAIL</a>", "<a href='http://hotmail.com'>HOTMAIL</a>"
    Then in the SSRS Reporting, I have placed a PlaceHolder with HTML View selected and gave above field value in the expression.
    They are not appearing as comma separated Hyperlinks.
    Can anyone please help me on this ? What are the changes required in above steps ?
    Thank you,
    Mittal.

    Hi Mittal,
    According to your description, you want to show three links together with comma separated from BCMProgramDocument column to a report table. After testing the issue in my environment, we can refer to the following steps to achieve your requirement:
    Use the following query create a dataset:
    select * from BCMProgramDocumentation
    Click Fields in the left pane, add a Calculated Field as below:
    Field Name: ID2                     Field Source: 1
    Drag a table to design surface, then insert the expression below in the detail row:
    =JOIN(lookupset(Fields!ID2.Value,Fields!ID2.Value,Fields!BCMProgramDocument.Value,"DataSet1"),",")
    Right-click the Placeholder to open Placeholder Properties, then select ‘HTML-Interpret HTML tags as styles’ as Markup type.
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

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

  • Problem using comma separated list with nested table element

    Hi,
    I have a comma separated list like that:
    H23004,H24005,T7231,T8231,T9231And want to create a function which is creating a where clause for each element with an output like that:
    UPPER('H23004') IN (UPPER(charge))
    OR UPPER('H23005') IN (UPPER(charge))
    OR UPPER('T7231') IN (UPPER(charge))
    OR UPPER('T8231') IN (UPPER(charge))
    OR UPPER('T9231') IN (UPPER(charge))Here is my test function which doesn't work correctly:
    create or replace function FNC_LIST_TO_WHERE_CLAUSE(v_list in VARCHAR2) return varchar2 is
    -- declaration of list type
    TYPE batch_type IS TABLE OF pr_stamm.charge%TYPE;
    -- variable for Batches
    v_batch batch_type := batch_type('''' || replace(v_list,',',''',''') || '''');
    return_script varchar2(1000);
    BEGIN
    -- loop as long as there are objects left
    FOR i IN v_batch.FIRST .. v_batch.LAST
    LOOP
       --DBMS_OUTPUT.PUT_LINE(offices(i));
       -- create where clause
       IF i = 1 THEN
         return_script := 'UPPER(' || v_batch(i) || ') IN (UPPER(charge))';
       ELSE
         return_script := return_script || ' OR UPPER(' || v_batch(i) || ') IN (UPPER(charge))';
       END IF;
    END LOOP;
    return (return_script);
    end;The out put looks like that:
    UPPER('H23004','H24005','T7231','T8231','T9231') IN (UPPER(charge))I have no idea what I do wrong? It calculates the amount of array element wrong! (v_batch.LAST should be 5.)
    v_batch.FIRST = 1
    v_batch.LAST = 1
    Regards,
    Tobias

    try this....
    declare
    text varchar2(1000) := 'H23004,H24005,T7231,T8231,T9231';
    v_where varchar2(1000);
    begin
    text := text||',';
    while instr(text,',') <> 0
    loop
    v_where := v_where || 'UPPER('''||substr(text,1,instr(text,',',1)-1)||''' IN (UPPER(charge)) OR ';
         text := substr(text,instr(text,',',1)+1);
    end loop;
    v_where := substr(v_where,1,length(v_where)-3);
    dbms_output.put_line(v_where);
    end;
    convert this one into function ...

  • 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

  • Currency with comma separator

    Hi all ,
    I have a currency filed TFULLVACWTG. I am summing all values like this
    TFULLVACWTG = VFWTG001 + VFWTG002 + VFWTG003 + VFWTG004 + VFWTG005 . iam getting output like  this 14092.00 i should get output like this 14,092.00
    I should write output with comma separator .is there any key word or f.m for this one?

    Hi Priya,
    You have two options.
    1) Changes in user master record ie change thousand separator as , and decimal separator as .(dot).
    You can do this with transaction SU3.
    2) If you dont want to change master record then try with this code.
    DATA VC_TFULLVACWTG(18).
    VC_TFULLVACWTG = TFULLVACWTG.
    TRANSLATE VC_TFULLVACWTG USING ',#'.
    TRANSLATE VC_TFULLVACWTG USING '.,'.
    TRANSLATE VC_TFULLVACWTG USING '#.'.
    WRITE VC_TFULLVACWTG.
    Thanks,
    Vinay

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

Maybe you are looking for

  • How to get the date for the first monday of each month

    Dear Members, How to get the date for the first monday of each month. I have written the following code SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL But it

  • Workbench automation

    I am looking for a way to generate all the toplink related files for a project without using the workbench gui. I have written some stuff to generate java classes from the database metadata but I realize that the workbench does the exact same work so

  • How to config MPLS with DHCP

    hi, i am novice in MPLS please help me to config below scenario , i want to config DHCP service on CE router (in picture:: CE2: Customer B ) which other CE (like CE1) can get IP address  assume that we have different IP range i want to enable DHCP on

  • My Facetime doesn't works, need help...

    I've tried to fix it, but doesn't works...

  • HT4972 HOW TO DOWNLOAD IOS 5

    who can let me know how to install ios5