Column to row

How to convert column to row in Oracle 10g.
Input
WB
CB
IT
CARDS
Output should be as follows.
WB|CB|IT|CARDS

declare
          var_result emp.ename%type := null;
begin
     for i in (select ename from emp)
     loop
          if i.ename is not null then
               var_result := var_result ||'|'|| i.ename ;
          else      
               var_result := var_result ;
          end if;
     end loop;
     var_result := substr(var_result,2) ;
     dbms_output.put_line('result is: '||var_result);
end;

Similar Messages

  • Interactive Report - Icon View - Dynamic Columns per Rows ?

    Hi all,
    We use the icon view functionnality in Interactive Report.
    Is there a way to display the 'columns per row' attribute as an application item and set it dynamical via PL/SQL ?
    Any suggestions?
    Thanks in advance for advices,
    Regards,
    Grégory

    Hi,
    Apex 4.0 interactive reports and images (Scott's thread)
    Have some useful information and pointers to the solution you are looking for.
    I hope this help.
    Thank you,
    Ranish

  • SWAP COLUMNS AND ROW IN AN INTERNAL TABLE to display in ALV

    Hi ,
    I want to swap all the rows in an internal table with the column of the internal table to display it horizontally in ALV grid.
    e.g
    1     2   3  (field names)
    A    P   X
    B    Q   Y
    C    R    Z
    should look like :
    D       A   B     C
    E      P   Q    R
    F       X    Y    Z
    Where D , E, F in first column is already apended in new table.
    Or else is there a way to rotate the ALV grid so that it can display rows as columns & columns as rows.
    regards

    hi,
    i have an internal table which is like
    f1  f2 f3  f4 (column header)
    A  1  2   3
    B  4  5   6
    C  7  8   9
    the values in o/p table should be
    A B C  ( column header)
    1  4 7 
    2  5 8
    3  6 9
    Please help!!

  • How to enter a data into the specified column and row in a created table

    Hi,
    I want to enter some data to specified column and row in a already created table. Please let me know how to do this.
    Regards
    Shivakumar Singh

    A table is just a 2D array of strings. Keep it in a shift register and use "replace array element" to modify the desired entry programmatically.
    If you want to modify it manually and directly from the front panel, make it into a control and type directly into the desired element. (In this case your program would need to write to it using a local variable).
    Atttached is a simple example in LabVIEW 7.0 that shows both possibilities.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ChangeTableEntries.vi ‏41 KB

  • Problem in displaying the data of columns into rows in sap script

    hi,
    i am working on a sap script and i have to display the dat which is displayed in column into rows but it is not displaying it properly.
    eg, C
        12.1
        Si
        5.5
    it is displaying the data right now like this but i want to display the  data like this:-
    eg, C      Si
        12.1   5.5
    plzzprovide me guidelines how to solve this problem.

    hi,
    i am using this code to display the data:-
    plzz provide me guidelines where i am getting wrong?
    TOPparCOMPONENT DESP,,,,,, INS. LOT #, , , , , , MIC,,,,,,,,,, MIC VALUEparENDTOPparFINAL
    PROTECT
    IF &I_FINAL-PRUEFLOS& NE '000000000000'
    &I_FINAL-MAKTX(23)&&i_final-prueflos(12Z)&
    &I_FINAL-kurztext(25)&
    &I_FINAL-original_input(8)&
    ELSE
    &I_FINAL-MAKTX(23)&     
    &I_FINAL-kurztext(25)&
    &I_FINAL-original_input(8)&
    ENDIF
    ENDPROTECT
    ITEMHEAD
    POSITION WINDOW
    SIZE WIDTH +0 . 4 CH HEIGHT +1 LN
    BOX FRAME 10 TW
    BOX HEIGHT '1.35' LN INTENSITY 20
    IF &PAGE& = '1'
    BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '43' LN FRAME '10' TW
    For horizontal line at top
    BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
    COLUMN LINES...
    END OF COLUMN LINES...
    BOX XPOS '0' CH YPOS '43' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
    BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '43' LN FRAME '10'TW
    ELSE
    COLUMN LINES...
    END OF COLUMN LINES...
    BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '0' CM WIDTH '45' CM HEIGHT '0' LN FRAME '10' TW
    BOX XPOS '20' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '47' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
    BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '47' LN FRAME '10'TW
    ENDIF
    LINEFEED
    NEWPAGE
    NEW-PAGE
    provide me guidelines to solve this problem.
    Edited by: ricx .s on Mar 13, 2009 5:58 AM

  • Filling in values based on the column and row headers

    I have a question that seems simple, but I can't figure out how to do it and I've searched all over the forum to no avail.
    I have one column that is width increasing by 3 in. increments (column A)
    I have one row that is height increasing by 3 in. increments (row B)
    I have one cell that is price (cell A1)
    I have a formula to calculate price per sq. ft.: =CEILING(A3B2/144,1)A1. This gives me the whole sq. ft. number multiplied by the price per sq. ft. to give me a total price at that dimension (A3 is the width, B2 is the height, and A1 is the cell that contains the price per sq. ft.).
    *Here is the problem*: When I try to cut and paste or fill the formula to the other cells, it doesn't calculate the formula as =CEILING(column A * Row B/144,1)*A1. Instead, it moves all of the values relative to the new cell that the formula is being pasted or filled to.
    Is there a way to autofill the cells so that the formula continues to refer to the width column, the height row, and the price cell?

    Aha! Apparently I didn't do enough research before I posted and I have since answered my own question. Here's how you do it. Look for "Distinguishing Absolute and Relative Cell References" and you should be able to find what you need. In my case, here is the formula I needed to have to make the copy and paste function do what I needed it to do: =CEILING($A3*B$2/144,1)*$A$. Hope that helps anyone who may have had the same problem I did.

  • How to get the current selected column and row

    Hi,
    A difficult one, how do i know which column (and row would also be nice) of a JTable is selected?
    e.g.
    I have a JButton which is called "Edit" when i select a cell in the JTable and click the button "Edit" a new window must be visible as a form where the user can edit the a part of a row.
    Then the column which was selected in the JTable must be given (so i need to know current column) and then i want the TextField (the one needed to be edited) be active with requestFocus(). So it would be
    pricetextfield.requestFocus();
    Problem now is that i have to click every time in the window the JTextField which was selected in the JTable. I have chosen for this way of editing because my application is multi-user and it would be too difficult for me when everybody did editing directly (catch signals, reload data, etc.).
    My question is how do I know the current column and the current row in a JTable?

    I'm not sure what your mean by the "current" row or column, but the following utility methods return
    which row and column have focus within the JTable.
    public static int getFocusRow(JTable table) {
        return table.getSelectionModel().getLeadSelectionIndex();
    public static int getFocusColumn(JTable table) {
        return table.getColumnModel().getSelectionModel().getLeadSelectionIndex();
    }

  • Please help to generate the table from column to rows

    Hello -
    I have one table with more than 100 columns there are 70 column start with HC1.....HC70 (they are not in sequence) and has some value 0 or 1
    Table structure:
    HICN_ID HC1 HC2 HC4 HC5 HC6.................................HC70
    1234A 0 1 1 0 1 1
    3456D 1 0 0 1 0 0
    Now What i want is like this..
    HICN_ID HC
    1234A 2
    1234A 4
    1234A 6
    3456D 1
    3456D 5
    Can you please help me on this
    thanks
    nick

    Please look at the same scenario from the below link.
    You can accomplish this by a "pivot" query. Please look at the small testcase that I prepared below:
    SQL> desc t1
    Name Null? Type
    NAME VARCHAR2(10)
    YEAR NUMBER(4)
    VALUE NUMBER(4)
    SQL>
    SQL> select * from t1;
    NAME YEAR VALUE
    john 1991 1000
    john 1992 2000
    john 1993 3000
    jack 1991 1500
    jack 1992 1200
    jack 1993 1340
    mary 1991 1250
    mary 1992 2323
    mary 1993 8700
    9 rows selected.
    SQL> -- now, try out the pivot query
    SQL> select year,
    2 max( decode( name, 'john', value, null ) ) "JOHN",
    3 max( decode( name, 'jack', value, null ) ) "JACK",
    4 max( decode( name, 'mary', value, null ) ) "MARY"
    5 from
    6 (
    7 select name, year, value
    8 from t1
    9 )
    10 group by year ;
    YEAR JOHN JACK MARY
    1991 1000 1500 1250
    1992 2000 1200 2323
    1993 3000 1340 8700
    SQL>
    Hope that helps.
    Source : http://p2p.wrox.com/oracle/11931-sql-query-convert-columns-into-rows.html
    Thanks,
    Balaji K.

  • [CS2/CS3 JS] Inserting columns or rows in tables

    Anybody here know how to insert or add column(s)/row(s) in tables in Indesign Javascript? Please help... Thanks...

    Hi Joaquin,
    you might have to take use of the add()-command:
    Add a column before the first column:
    myTable.columns.add( LocationOptions.BEFORE, myTable.columns[0] );
    Add a row after the last row:
    myTable.rows.add( LocationOptions.AFTER, myTable.rows[-1] );
    Martin

  • ALV to select more than one column by row using set_table_for_first_display

    Hello everyone,
    I am developing an application (ALV OO) to select more than 1 column by row ( one ). This is an a holiday application so the idea is:
    -One column will be the day, and the row will be the user.
    So I am trying to select more than one day by user (that would be the row).
    I am using the method set_table_for_first_display but when it shows the alv, doesn't let me to select more than one column with a click of the mouse.
    Does anybody know if I can do this (select more than one column, by row) in somehow?
    Please let me know if you need more clarification about this.
    Thanks in advance
    Diego

    Hi Diego,
    it's all in the documentation.
    set different selection modes through the value of the field u201CSEL_MODEu201D in the layout structure.
    SPACE
    same as 'B'
    see 'B'
    Default setting
    'A'
    Column and row selection
    Multiple columns
    Multiple rows
    The user selects the rows through pushbuttons at the left border of the grid control.
    'B'
    Simple selection, list box
    Multiple columns
    Multiple rows
    'C'
    Multiple selection, list box
    Multiple columns
    Multiple rows
    'D'
    Cell selection
    Multiple columns
    Multiple rows
    Any cells
    The user selects the rows through pushbuttons at the left border of the grid control
    Beyond setting this option, you can set u201CNO_ROWMARKu201D option to hide the mark column which is normally visible when the selection mode allows multiple row selection.
    One point to notice here is that if you set your ALV Grid as to be editable, it may override your selection mode regardless of your layout settings.
    This is from SDN Community Contribution "An Easy Reference for ALV Grid Control" By: Serdar ŞİMŞEKLER
    Sorry, no link,. it's on my disk.
    Regards,
    Clemens

  • Column to row conversion using script

    Hello,
    I am in need of a script to convert a file having 1 column to rows.
    e.g
    File is having entries like below
    1
    2
    3
    4
    5
    And I want to convert them like below.
    1 2 3 4 5
    Can any body help me on this ?
    Thank you
    Regards,
    ~Anoop

    Please show what you type.
    I test my example.
    For 10st post
    #!/bash - This line must present
    For my example - attantion - first comannd printf
    You result look like you type print
    Regards.
    Edited by: Nik on 28.06.2011 11:44

  • Read words from text file by delimiter as columns and rows

    Hi All,
    I need your help as i have a problem with reading string by delimiter. i have used various tech in java, but i can not get the result as expected.
    Please help me to get the string from text file and write into excel . i have used a text file.
    problem
    get the below as string by delimiter
    OI.ID||'|'||OI.IDSIEBEL||'|'||OI.IDTGU||'|'||OI.WORKTYPE||'|'||OI.UTR_FK
    read the below as string by delimiter
    "50381|TEST_7.15.2.2|09913043548|Attivazione|07-SEP-10
    now i need to write the above into excel file as columns and rows.
    there are 5 columns and each corresponding values
    the outut excel should be
    OI.ID OI.IDSIEBEL OI.IDSIEBEL OI.WORKTYPE OI.UTR_FK
    50381 TEST_7.15.2.2 09913043548 Attivazione 07-SEP-10
    i tried in diffrerent techinq but not able to get the resule. pls help me
    Thanks,
    Jasmin
    Edited by: user13836688 on Jan 22, 2011 8:13 PM

    First of all, when posting code, put it between two tags.
    Second of all, the pipe is a special character in regex, so you need to escape it as
    .split("\ \|");
    Erh. So 2 backslashes before the pipe character. Stupid forum won't post it.
    Edited by: Kayaman on Jan 24, 2011 9:35 AM
    Edited by: Kayaman on Jan 24, 2011 9:35 AM
    Edited by: Kayaman on Jan 24, 2011 9:36 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to display the rows in to columns and columns into rows?

    DES:- I know by using pivot and unpivot you can convert rows into columns and columns into rows but i don't know how to write the syntax?

    Hi,
    Besides the places Martin mentioned above, there are many examples in the forum FAQ:
    https://community.oracle.com/message/9362005#9362005
    For an example of both PIVOT and UNPIVOT in the same query, see
    http://forums.oracle.com/forums/thread.jspa?threadID=920854&tstart=0

  • Can anybody help....SQL to display row as column and column as rows

    Can anybody help in writing a SQL to display row as column and column as rows?
    Thanks

    check this link:
    Re: Creating Views - from rows to a new column?

  • Need help with query for converting columns to rows

    Hello,
    I know this is a very common question asked in the forum. I have searched regading this, i did find some threads, but i was not able to achieve what i require from the answers posted. So anybody please help me.
    I have a table which is having multiple columns as follows:
    Insert into table_1 (X,Y,Z,A,B,C,D,E,F,G,H,I) values (0,0,2,0,0,1,3,0,0,0,0,0);I want to convert the result into a two column, multiple rows i.e., I want the result as follows:
    Col1 Col2
    X      0
    Y     0
    Z      2
    A     0
    B     0
    C     1
    D     3
    E     0
    F     0
    G     0
    H     0
    I      0Please anybody help me in writing the query for this..

    Is this what you are expecting:
    SQL> WITH T AS
      2  (
      3  SELECT 0 X, 0 Y, 2 Z, 0 A, 0 B, 1 C, 3 D, 0 E, 0 F, 0 G, 0 H, 0 I FROM DUAL
      4  )
      5  SELECT  'X' col1, X col2 FROM T
      6  UNION ALL
      7  SELECT  'Y' col1, Y col2 FROM T
      8  UNION ALL
      9  SELECT  'Z' col1, Z col2 FROM T
    10  UNION ALL
    11  SELECT  'A' col1, A col2 FROM T
    12  UNION ALL
    13  SELECT  'B' col1, B col2 FROM T
    14  UNION ALL
    15  SELECT  'C' col1, C col2 FROM T
    16  UNION ALL
    17  SELECT  'D' col1, D col2 FROM T
    18  UNION ALL
    19  SELECT  'E' col1, E col2 FROM T
    20  UNION ALL
    21  SELECT  'F' col1, F col2 FROM T
    22  UNION ALL
    23  SELECT  'G' col1, G col2 FROM T
    24  UNION ALL
    25  SELECT  'H' col1, H col2 FROM T
    26  UNION ALL
    27  SELECT  'I' col1, I col2 FROM T
    28  /
    C       COL2                                                                   
    X          0                                                                   
    Y          0                                                                   
    Z          2                                                                   
    A          0                                                                   
    B          0                                                                   
    C          1                                                                   
    D          3                                                                   
    E          0                                                                   
    F          0                                                                   
    G          0                                                                   
    H          0                                                                   
    C       COL2                                                                   
    I          0                                                                   
    12 rows selected.

Maybe you are looking for