How to convert single column into single row

I need to convert single column into single row having n no.of.values in a column. without using case or decode. I need a query to display as below.
emp_id
100
101
102
102
103
200
I need output like 100,101,102,103,104.........200.

I assume you want to convert 200 rows with one column into one row with 200 columns. If so, this is called pivot. If you know number of rows (max possible number of rows) and you are on 11G you can use PIVOT operator (on lower versions GROUP BY + CASE). Otherwise, if row number isn't known, you can use dynamic SQL or assemble select on clent side. Below is example emp_id = 1,2,..5 (to give you idea) and you are on 11G:
with emp as (
             select  level emp_id
               from  dual
               connect by level <= 5
select  *
  from  emp
  pivot(
        max(emp_id) for emp_id in (1 emp_id1,2 emp_id2,3 emp_id3,4 emp_id4,5 emp_id5)
   EMP_ID1    EMP_ID2    EMP_ID3    EMP_ID4    EMP_ID5
         1          2          3          4          5
SQL>
SY.

Similar Messages

  • How to convert erl scripts into single exe file ?

    hi
    this is not related to java. Does anybody know how to convert perl scripts into exe file in non-readable format?
    regards
    venki

    I believe that ActiveState used to do a Perl compiler.....not sure if they still do and I don't think it was free anyway. Check around their website...
    http://www.activestate.com/

  • How to Convert a Column value to Rows which has ';' as delimitter.

    COLA COLB
    1 London University; Harvard University(1947; Masters; Distinction); Stanford University(1948, Masters; Distinction); Cambridge University(1949; Graduation, First class)
    Which needs to be transformed as
    COLA COLB
    1 London University
    1 Harvard University(1947 Masters Distinction)
    1 Stanford University(1948, Masters Distinction)
    1 Cambridge University(1949 Graduation, First class)
    Thanks in Advance.
    Regards,
    Balakrishna

    maybe this example might help.
    SQL> select trim(replace(decode(c.semicolon_pos,0,substr(c.str,decode(c.lg,0,1,c.lg)),substr(c.str,decode(c.lg,0,1,c.lg),(c.semicolon_pos - c.lg))),';',null)) single_string
      2    from (select b.rn, b.str, b.semicolon_cnt, b.semicolon_pos,
      3                 nvl(lag(b.semicolon_pos) over (order by b.rn, b.str),0) lg
      4            from (select rownum rn, a.str, a.semicolon_cnt,
      5                         instr(a.str,';',1,rownum) semicolon_pos
      6                    from (select vt.str,
      7                                 (length(vt.str) - length(replace(vt.str, ';'))) semicolon_cnt
      8                            from (select '1 London University; Harvard University(1947, Masters, Distinction); Stanford University(1948, Masters, Distinction); Cambridge University(1949, Graduation, First class)' str from dual) vt) a
      9                  connect by level <= a.semicolon_cnt+1) b) c;
    SINGLE_STRING
    1 London University
    Harvard University(1947, Masters, Distinction)
    Stanford University(1948, Masters, Distinction)
    Cambridge University(1949, Graduation, First class)
    SQL>

  • How to Splilit The String Into Single Column using Comma As Delimiter ?

    How to Splilit The String Into Single Column using Comma As Delimiter ?
    using Function

    refer my thread ,code is also available see if that helps you
    error while executing the sp ORA-21779: duration not active

  • How to make few columns of single record inactive in Table conrol?

    Hi all,
    Scenario is like this : i have one table control , it is displaying 10 records , in that first four columns are editable. Now my requirement is, whenever record having intial values( suppose one record having initial values among ten) except key field , we need to deactive that particular  record , now table control  should contain ten records , but nine records are in editable state and one record in non editable state .
    How to make few columns of single record inactive in Table conrol?
    Thanks in advance.

    hi there...
    select the column that u want to convert to non editable mode in the screen layout. then double click on it. go to the attributes tab and uncheck the input chk box. the check box will become disabled for input. u can do this for any number of columns.
    if u want to do it dyanamically, loop at screen. check for the screen element's name. when itmatches the column u want to disable, simply set the input value as 0.
    dont forget to modify sscreen after setting the attribute values.
    i hope this helps.
    do reward if helpful.

  • 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

  • How to Pass multiple parameter into single store procedure

    How to Pass multiple parameter into single store procedure
    like a one to many relationship.
    it is possible then reply me immediatly

    you mean like this .....
    CREATE OR REPLACE procedure display_me(in_param in varchar2,in_default in varchar2 := 'Default') is
    BEGIN
    DBMS_OUTPUT.put_line ('Values is .....'||in_param || '....'||in_default);
    END display_me;
    CREATE OR REPLACE procedure display_me_2 as
    cnt integer :=0;
    BEGIN
    For c1_rec In (SELECT empno,deptno FROM test_emp) Loop
         display_me(in_param => c1_rec.empno);
         cnt := cnt+1;
         end loop;
         DBMS_OUTPUT.put_line('Total record count is ....'||cnt);
    END display_me_2;
    SQL > exec display_me_2
    Values is .....9999....Default
    Values is .....4567....Default
    Values is .....2345....Default
    Values is .....7369....Default
    Values is .....7499....Default
    Values is .....7521....Default
    Values is .....7566....Default
    Values is .....7654....Default
    Values is .....7698....Default
    Values is .....7782....Default
    Values is .....7788....Default
    Values is .....7839....Default
    Values is .....7844....Default
    Values is .....7876....Default
    Values is .....7900....Default
    Values is .....7902....Default
    Values is .....7934....Default
    Values is .....1234....Default
    Total record count is ....18

  • How to convert HL7 file into an XML

    Hi All,
    I am new to HL7,can any one tell how to convert HL7 file into an XML.Give sample demo or related links.
    My sample HL7 file is as follows how can I convert.
    FHS|^~\&||Tax ID123^Lab Name123^L|||201110191435||HL7.txt||1234567|123||
    PID|seqno|123||john^chambers^^Dr^Dr|2456 california ave^San jose^CA^85254|19601212|M
    FHS|^~\&||Tax ID123^Lab Name123^L|||File Creaqted Date|File Security|FileName||File HeaderComment||Facility|FileCreatedDateTime|File Security|File Name|File Header Comment|FileControlId|Reference File Control ID|
    PID|seqno|patientId||LastName^FirstName^MiddleName^Title^Degree|Street^City^State^zip|patientDOB|gender
    <Report>
    <FileHeader>
    <FileSendingApplication> </FileSendingApplication>
    <TaxID>Tax ID123</TaxID>
    <LabName>Lab Name123</LabName>
    <FileSendngFacilityType>L</FileSendngFacilityType>
    <FileReceivingApplication></FileReceivingApplication>
    <FileReceivingFacility></FileReceivingFacility>
    <FileCreatedDateTime>201110191435</FileCreatedDateTime>
    <FileSecurity></FileSecurity>
    <FileName>HL7.txt</FileName>
    <FileHeaderComment></FileHeaderComment>
    <FileControlId>1234567</FileControlId>
    <ReferenceFileControlID></ReferenceFileControlID>
    <FileHeader>
    <Patient>
    <seqno> </seqno>
    <patientId>Tax ID123</patientId>
    <LastName>Lab Name123</LastName>
    <FirstName>L</FirstName>
    <MiddleName></MiddleName>
    <Title> </Title>
    <Degree></Degree>
    <Street></Street>
    <City></City>
    <State>HL7.txt</State>
    <Zip></Zip>
    <patientDOB>1234567</patientDOB>
    <gender></gender>
    <Patient>
    </Report>
    Thanks
    Mani

    Hi Prabu,
    With input as in single line I'm able to get the the output but with the multiple lines of input,error was occured.Any suggestions.
    Error while translating. Translation exception. Error occured while translating content from file C:\temp\sampleHL7.txt Please make sure that the file content conforms to the schema. Make necessary changes to the file content or the schema.
    The payload details for this rejected message can be retrieved.          Show payload...
    Thanks
    Mani

  • How to convert table content into html format?

    Hi,
    Experts,
    How to convert internal data into HTML format is there any function module or piece of code to download content into HTML.
    Thank u,
    Shabeer Ahmed.

    Then use this code....
    REPORT  ytest_table_html1.
    *        D A T A   D E C L A R A T I O N
    *-HTML Table
    DATA:
      t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE,
                                           " Html Table
    *- Declare Internal table and Fieldcatalog
      it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE,
                                           " Flights Details
      it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
                                           " Fieldcatalog
    *-Variables
    DATA:
      v_lines TYPE i,
      v_field(40).
    *-Fieldsymbols
    FIELD-SYMBOLS: <fs> TYPE ANY.
    *        S T A R T - O F - S E L E C T I O N
    START-OF-SELECTION.
      SELECT *
        FROM sflight
        INTO TABLE it_flight
        UP TO 20 ROWS.
    *        E N D - O F - S E L E C T I O N
    END-OF-SELECTION.
    *-Fill the Column headings and Properties
    * Field catalog is used to populate the Headings and Values of
    * The table cells dynamically
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'SFLIGHT'
        CHANGING
          ct_fieldcat            = it_fcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2.
      DELETE it_fcat WHERE fieldname = 'MANDT'.
      t_html-line = '<html>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<td><h1>Flights Details</h1></td>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<table border = "1">'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
    *-Populate HTML columns from Filedcatalog
      LOOP AT it_fcat.
        CONCATENATE '<th bgcolor = "green" fgcolor = "black">'
            it_fcat-scrtext_l
            '</th>' INTO t_html-line.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      DESCRIBE TABLE it_fcat LINES v_lines.
    *-Populate HTML table from Internal table data
      LOOP AT it_flight.
        t_html-line = '<tr>'.
        APPEND t_html.
        CLEAR t_html.
    *-Populate entire row of HTML table Dynamically
    *-With the Help of Fieldcatalog.
        DO v_lines TIMES.
          READ TABLE it_fcat INDEX sy-index.
          CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field.
          ASSIGN (v_field) TO <fs>.
          t_html-line = '<td>'.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = <fs>.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = '</td>'.
          APPEND t_html.
          CLEAR t_html.
          CLEAR v_field.
          UNASSIGN <fs>.
        ENDDO.
        t_html-line = '</tr>'.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</table>'.
      APPEND t_html.
      CLEAR t_html.
    *-Download  the HTML into frontend
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'C:\Flights.htm'
        TABLES
          data_tab                = t_html
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    *-Display the HTML file
      CALL METHOD cl_gui_frontend_services=>execute
        EXPORTING
          document               = 'C:\Flights.htm'
          operation              = 'OPEN'
        EXCEPTIONS
          cntl_error             = 1
          error_no_gui           = 2
          bad_parameter          = 3
          file_not_found         = 4
          path_not_found         = 5
          file_extension_unknown = 6
          error_execute_failed   = 7
          synchronous_failed     = 8
          not_supported_by_gui   = 9
          OTHERS                 = 10.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    none of the above function modules r obsolete...

  • How to put 2nd column into 1st column in excel

    Hello,
    I have a question how to put 2nd column into 1st column in excel. Thank you.
    Solved!
    Go to Solution.

    Why the 1 iteration for loops?
    Why the two Index Arrays?  It is just trying to fix the problem created by the For Loops on the original 1-D arrays.
    Both of those things are creating 2-D arrays that are complicating things and can be eliminated.
    You can take your 2 1-D arrays, use Build Array and right click to set "Concatenate Inputs".
    If you do have a 2-D array, you can use Reshape Array to make it a 1 column by N row 2-D array.

  • Every two charater of a column into a row

    Hello everyone,
    I am trying to convert every two characters of a column into a row.
    Something like...
    with t as
    SELECT
              '00112233445566778899' TN
                 FROM dual
    --union all
    --select 'xxyyzzaabbccddeeffgg' from
    --dual
    SELECT SUBSTR 
             ( tn 
             , decode(n,0,0,(((n*2)+1)-2))
             , 2
             ) AS token  ,n
        FROM ( select * from t
           , ( SELECT LEVEL n
                 FROM (SELECT length(tn)/2 max_elements FROM t)
              CONNECT BY LEVEL <= max_elements +30
       WHERE n <= LENGTH(tn) /2
    TO          N
    00          1
    11          2
    22          3
    33          4
    44          5
    55          6
    66          7
    77          8
    88          9
    99         10The above query fails when I try to do it for multiple rows(It goes in an infinite loop).
    Is there a way to convert ever two characters of a column into a row.
    I am using Oracle 9i.
    Thanks in Advance,
    Jaggyam

    jaggyam wrote:
    Note : I am using 9i.It's usually a good idea to mention that at the beginning otherwise we have to assume you are using the latest/supported versions of oracle.
    Does this work in 9i.... (I don't have an old version to try it on)
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '00112233445566778899' as txt from dual union all
      2             select 'aabbccddeeff' from dual)
      3      ,m as (select max(length(txt)/2) mx from t)
      4  --
      5  select txt
      6  from (
      7    select substr(txt, ((rn-1)*2)+1, 2) as txt
      8    from t, (select rownum rn from m connect by rownum <= mx)
      9    )
    10* where txt is not null
    SQL> /
    TX
    00
    aa
    11
    bb
    22
    cc
    33
    dd
    44
    ee
    55
    ff
    66
    77
    88
    99
    16 rows selected.
    SQL>

  • Converting multiple columns into one.

    All,
    I have a requirement to convert multiple columns into one. Following is the pseudo code of current implementation. It unions the various columns ( col1, col2........) into a new column new_col. But perforamnce is extrmely slow owing to multiple unions. It may be noted that tables and where conditions of all these queries are same.
    Can you help me create a more efficient query?
    select col1 , col2, col3, col4 from my_tables where some_cols = my_condition;Below is the query used to convert these columns into one.
    select col1 new_col from my_tables where some_cols = my_condition
    union all
    select col2 from my_tables where some_cols = my_condition
    union all
    select col3 from my_tables where some_cols = my_condition
    union all
    select col4 from my_tables where some_cols = my_condition

    Without looking at those things you could be barking up the wrong tree by assuming the issue relates to the unioning of queries or other such things.Well, might be.........
    Execution time of this query (just the execution time not the retrival) is around 34 seconds with connect-by clause for returning 22,000 records.
    Here's the plan
    Execution Plan
    | Id  | Operation                          | Name                        | Rows
    | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT                   |                             |   326
    | 33904 |   135   (2)|
    |   1 |  SORT ORDER BY                     |                             |   326
    | 33904 |   135   (2)|
    |   2 |   MAT_VIEW ACCESS BY INDEX ROWID   | MV_COMQ_RM_DEAL             |     1
    |    62 |     1   (0)|
    |   3 |    NESTED LOOPS                    |                             |   326
    | 33904 |   134   (1)|
    |   4 |     MERGE JOIN CARTESIAN           |                             |   326
    | 13692 |     3   (0)|
    |   5 |      VIEW                          |                             |     1
    |    13 |     2   (0)|
    |   6 |       COUNT                        |                             |
    |       |            |
    |   7 |        CONNECT BY WITHOUT FILTERING|                             |
    |       |            |
    |   8 |         FAST DUAL                  |                             |     1
    |       |     2   (0)|
    |   9 |      BUFFER SORT                   |                             |   326
    |  9454 |     3   (0)|
    |  10 |       TABLE ACCESS BY INDEX ROWID  | SF_SEARCH_IDS_TMP_COMQ      |   326
    |  9454 |     1   (0)|
    |  11 |        INDEX RANGE SCAN            | IDX1_SF_SEARCH_IDS_TMP_COMQ |   349
    |       |     1   (0)|
    |  12 |     INDEX RANGE SCAN               | IDX_MV_COMQ_RM_DEAL         |     9
    |       |     1   (0)|
    -----------------------     Hope, It's readable.......
    I would have posted sample data and query but........I cant do that...:(

  • How to convert DataServices.Result into an Arraylist or ArrayCollection?

    I want to use an ArrayCollection or an ArrayList as a data provider
    for a dataGrid, and then later in a Graph.
    The problem is that the starting point is the FLEX Builder 4 created "datasource.lastResult" value Objects.
    I don't know how to access anything but the Column names.
    The fields returned are:
         gmtdate,hostname,CPUBusy
    I want to show CPU busy for "N" number of hosts.
    So I need to change my result from the SQL query in Action Script into:
        gmtdate, hostname1_CPUbusy, hostname2_CPUbusy, hostnameN_CPUbusy
    Are there any samples of how to convert the .lastResult into an ArrayList?
    The result set is Object based and I can't figure out how to read it.
    Thanks,
    David

    I wish I could change it, but Oracle SQL does not allow for an unknown number of hosts.
    Nor does this version of Oracle have the new pivot function.
    David

  • How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie

    How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie -  simple answers please - Thanks in advance.

    @Pipeline2007 - which version of Microsoft Office have you got? Older versions of Acrobat aren't compatible with the latest versions of Office, see this link for info:
    http://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html

  • How to convert jpeg files into word

    How to convert jpeg files into Word

    Hi Eugene,
    I don't think you can convert an image to a Word document, but you could place the JPEG into a Word document using the Insert > Object command in Word.
    For other questions relating to Word, you will probably have more luck getting an answer if you post on the Microsoft forums (we can help if you're using Acrobat, or another Adobe product, but you'll find the Word experts on the Microsoft forums.)
    Best,
    Sara

Maybe you are looking for

  • Disappearance of alert message from alert inbox

    XI Experts, We are using XI 7.0, We have configure alerts for many of our scenario and it is working good. Whenever messages is failed in IE or AE we get an alert in our alert inbox in RWB and for MS outlook. But I observed that alert messages disapp

  • Using DB Link for SQL Server

    Hi All, When I query the SQL server table from Oracle using DB Link, it works fine for any table: select * from testtable@DBLINK test -- This statement works fine because I am giving * i.e. all columns But when I try to query specific columns like Se

  • Scrolling window appears - How do I remove?

    Here is a page created with my template: http://abdavisbuilders.com/contact.html Here is another page created with the same template, but adding copy and a few divs: http://abdavisbuilders.com/index-2.html You will notice that the contact page does n

  • Print PDF to Aperture...

    I just bought Aperture 3 from the Mac App Store. When I had the trial version of Aperture 3 I had the PDF to Aperture option when I would print from a web page or any other print dialog. I think I removed it when I uninstalled the trial. Now that I h

  • WRT54G.v5 problem - website's security certificate

    I am getting this message when trying to install my router/change settings.  "The security certificate presented by this website was not issued by a trusted certificate authority".  The security certificate presented by this website was issued for di