Retriving data : Rows to column.

Please help in getting the query for the below problem:
There are 2 table DEPT and EMP.I want to get the data "FOR EACH DEPARTMENT ALL THE EMPLOYES SHOULD BE DISPLAYED IN ONE ROW" :
DEPT_ID EMP_NAME
10 JOHN,TINA,RAVI,CHIRS
20 JOE,MIT,MICHALE
30 HARI,KRISHNA,PEMMASANI

Assuming you are on 11.2:
select  deptno,
        listagg(ename,',') within group(order by ename) ename_list
  from  emp
  group by deptno
select  deptno,
        listagg(ename,',') within group(order by ename) ename_list
  from  emp
  group by deptno
    DEPTNO ENAME_LIST
        10 CLARK,KING,MILLER
        20 ADAMS,FORD,JONES,SCOTT,SMITH
        30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
SQL>For older versions:
select  deptno,
        rtrim(xmlagg(xmlelement(e,ename,',').extract('//text()') order by ename),',') ename_list
  from  emp
  group by deptno
    DEPTNO ENAME_LIST
        10 CLARK,KING,MILLER
        20 ADAMS,FORD,JONES,SCOTT,SMITH
        30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
SQL>SY.

Similar Messages

  • 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 can i open a PDF bank statement in numbers so that the rows and columns contain properly aligned data from statement?

    how can i open a PDF bank statement in "numbers" so that the rows and columns contain properly aligned data from statement?

    Numbers can store pdfs pages or clippings but does not directly open pdf files.  To get the bank statement into Numbers as a table I would open the bank statment in Preview (or Skim) or some pdf viewer.
    Then hold the option key while selecting a column of data.
    Then copy
    Then switch to numbers and paste the column into a table
    Then repeat for the other columns in the pdf document
    It would be easier (in my opinion) to download the QFX or CSV version from your bank

  • Row and Column Formulas on a Data Form

    I am creating a data form which has both row and column formulas. I would like the row formulas to show for some of the cells but it seems to default to the column formula.
    How can I get my form to show the row formula result and not the column formula result?
    Thank you!

    Brian,
    See this example:
    http://htmldb.oracle.com/pls/otn/f?p=31517:160
    There are also a coupleof others showing the same thing you want to achive.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (NumberOfMultipleMatches).

    Hi,
    I have a file where fields are wrapped with ".
    =========== file sample
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    ==========
    I am having a .net method to remove the wrap characters and write out a file without wrap characters.
    ======================
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    ======================
    the .net code is here.
    ========================================
    public static string RemoveCharacter(string sFileName, char cRemoveChar)
                object objLock = new object();
                //VirtualStream objInputStream = null;
                //VirtualStream objOutStream = null;
                FileStream objInputFile = null, objOutFile = null;
                lock(objLock)
                    try
                        objInputFile = new FileStream(sFileName, FileMode.Open);
                        //objInputStream = new VirtualStream(objInputFile);
                        objOutFile = new FileStream(sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString(), FileMode.Create);
                        //objOutStream = new VirtualStream(objOutFile);
                        int nByteRead;
                        while ((nByteRead = objInputFile.ReadByte()) != -1)
                            if (nByteRead != (int)cRemoveChar)
                                objOutFile.WriteByte((byte)nByteRead);
                    finally
                        objInputFile.Close();
                        objOutFile.Close();
                    return sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString();
    ==================================
    however when I run the bulk load utility I get the error 
    =======================================
    Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (NumberOfMultipleMatches).
    ==========================================
    the bulk insert statement is as follows
    =========================================
     BULK INSERT Temp  
     FROM '<file name>' WITH  
      FIELDTERMINATOR = ','  
      , KEEPNULLS  
    ==========================================
    Does anybody know what is happening and what needs to be done ?
    PLEASE HELP
    Thanks in advance 
    Vikram

    To load that file with BULK INSERT, use this format file:
    9.0
    4
    1 SQLCHAR 0 0 "\""      0 ""    ""
    2 SQLCHAR 0 0 "\",\""   1 col1  Latin1_General_CI_AS
    3 SQLCHAR 0 0 "\",\""   2 col2  Latin1_General_CI_AS
    4 SQLCHAR 0 0 "\"\r\n"  3 col3  Latin1_General_CI_AS
    Note that the format file defines four fields while the fileonly seems to have three. The format file defines an empty field before the first quote.
    Or, since you already have a .NET program, use a stored procedure with table-valued parameter instead. I have an example of how to do this here:
    http://www.sommarskog.se/arrays-in-sql-2008.html
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SQL Developer problem. Rows without columns on data tab

    Hello,
    I have a strange behavior in Oracle SQL Developer Version 2.1.0.63. When I'm trying to open the "Data tab" for some tables, SQL Developer shows data rows but without columns! It seems that I can select different rows but I can't see neither any data nor column names.
    Under the filter setting there are no available columns either.
    At the same time, when I'm trying to open sys tables they are displayed normally.
    From the other side, those tables which are not displayed correctly in 2.1.0.63, could be opened in Version 1.5.5 without any problems.
    Do you have any ideas?
    Thanks in advance.

    Hi,
    Refer to the SQL Developer forum: SQL Developer for SQL Developer related questions

  • How to convert data from rows into columns

    Hi,
    I have a sql table and the data looks like this
    GLYEAR GLMN01 GLMN02 GLMN03 GLMN04
    2007 -109712.40 6909.15 4758.72 56.88
    2007 -13411.32 19132.9 -5585.07 4362.64
    Where GLyear reprsents Year and GLMN01 is February, GLMN02 is March and so on,
    Now i want my output to be something like this which i want to insert into another table
    GLYear GLMonth GLAmount
    2007 February -109712.40
    2007 March 6909.15
    2007 April 56.88
    My new table has 3 columns, GLYear,GLMonth,GLAmount.
    Can someone please help me with the select statement on how to do this, i can work with the inserts.
    Thanks.

    I want you to check these form tread they have the same discussion as you.  They will definitely solve your problem
    http://blog.jontav.com/post/8344518585/convert-rows-to-columns-columns-to-rows-in-sql-server
    http://dba.stackexchange.com/questions/19057/convert-rows-to-columns-using-pivot-in-sql-server-when-columns-are-string-data
    http://stackoverflow.com/questions/18612326/how-to-convert-multiple-row-data-into-column-data-in-sql-server
    I hope this helps you in solving your problem. 
    Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer

  • Rows and column limit on Data Grids

    Hello,
    anyone know if there's a limit for the number of rows and columns per page in the Data Grids?
    Thanks in advance

    There is not a limit. There is a default of 1024 rows, but you can change this.
    -- Chris

  • Exporting data in rows and columns and loading in RDBMS

    <p>I have a scenario wherein i want to export data from HyperionEssbase in <b>rows and coulmns</b> and <b>load it into</b><b>RDBMS</b>. I can load data into RDBMS using informatica if theflat file exported is in form of rows and columns.But when i exportthe file using Hyperion Essbase 9 i get it in from of alldimensions and then the fact value which is not how i want. I wantdata in relational from in flat file itself(row,column).</p><p>Looking forard to your suggestions..Thanks in advance..</p>

    <p>Thanks <b>willjordan</b> and <b>twakim</b> for yoursuggestions..</p><p> </p><p>I tried both the techniques and both worked...</p><p>With reference to the technique suggested by <b>twakim</b> , I was able to use that in Hyperion Essbase 9..But in myreal scenario the cube is in Hyperion Essbase 6.5.4.2..Can i usethis Custom defined functions in Hyperion Essbase 6.5.4.2..and ifso how as there is no concept of Analytical server there???</p><p> </p><p>Please help me in this issue???<br></p>

  • Maximum number of rows and columns in data form

    Hi,
    I wanted to know if there is a limitation to the number of rows and columns that can be displayed in a data form, in Hyperion planning 11.1.2.1 ?
    And what would be the most appropriate number of rows and columns to be included for optimum performance.
    Thanks.

    Hi,
    While its a fun fact to determine how much one can stuff into a web form, the reality is: how much can a user reasonably consume in a web form?
    And what would be the most appropriate number of rows and columns to be included for optimum performance
    You will find that the answer to this is by "what design makes a web form most usable?" And no, the users don't really know what they want from a design perspective, they see it in their head, but usually what they ask for is something that would look entirely different (huge).
    The next thing to think about is the use of member selection functions in the page axis. IDescendants(Entity) in a dropdown could cause issues just as easily as too many rows - and again make the drop down unusable for a user.
    If your question is a bit more technical, then consider this (somewhat oversimplified): Web forms are constructed by a process on the server. Objects are created based on the form's definition and used by the process that builds the form. The process uses Cartesian looping (lots of iterations) to construct the form cell by cell, starting at the top left and finishing up in the bottom right. If the form has a million cells on it, then the loop and all the code within it runs a million times. The capability of the server has a lot to do with how well it can handle this request, and how many it can handle at one time.
    The result of this is gobs of HTML and JavaScript. All of this has to be sent over a network to the requesting client. The client starts receiving the web page code and has to render it in the browser and run the JavaScript. The ability to do this is limited by the browser, the OS, and the hardware that the client is running on.
    And that's just rendering the page for use.
    Now it has to be interacted with on the client machine, and changes parsed, packaged, and sent back to the server.
    So the technical answer is, there can be many limitations to how many rows and columns a data form can have - none of which can truly be anticipated by anyone. This is why I put the part about usability first in this post.
    Regards,
    Robb Salzmann

  • How to display 2 dimensional data. i.e with rows and columns?

    Hi,
    I want to know how to display multiple, variable
    rows and columns that are got from the database through
    queries in forms.
    (i,e. a Matrix of Values,something similar to an Excel Spreadsheet).
    Is there a component in forms similar to JTABLE that is
    available in Java through which MULTIPLE, VARIABLE
    rows and columns can be displayed ?.
    I am not using a base table since this data is got thru
    a number of packages and procedures that are used in
    Loops.
    NOTE : I am using forms 6i.
    Thanks
    Sharath.

    I've heard Grant mention adding a Grid component to the Forms toolbox. From the context I would guess this is not yet even under development, so it's not going to be available anytime soon. And not for 6i.
    Sorry, APC

  • Multiple row data converted to columns

    I've seen various solutions to this, but I have one caveat: how to do it in oracle 8i and make it dynamic for a variable number of rows to columns?
    Here is an example:
    TABLE layout (unit_id and hour-ending are the PKs)
    hour_ending DATE
    unit_id NUMBER
    net_gen NUMBER
    total_unit_id NUMBERHere's a sample of data if you selected it:
    UNIT_ID  HOUR_ENDING            NET_GEN
    5297     11/1/2005 1:00:00 AM   581    
    5298     11/1/2005 1:00:00 AM   318    
    5299     11/1/2005 1:00:00 AM   91     
    5300     11/1/2005 1:00:00 AM   59     
    5301     11/1/2005 1:00:00 AM   68     
    5302     11/1/2005 1:00:00 AM   45     
    5297     11/1/2005 2:00:00 AM   625    
    5298     11/1/2005 2:00:00 AM   341    
    5299     11/1/2005 2:00:00 AM   97     
    5300     11/1/2005 2:00:00 AM   64     
    5301     11/1/2005 2:00:00 AM   74     
    5302     11/1/2005 2:00:00 AM   49      Without having to "hard code" the ids and such, what I want to do is create an SQL query that will be dynamic to create a result set as follows:
    HOUR_ENDING           UNIT_ID1  NET_GEN1  UNIT_ID2  NET_GEN2  UNIT_ID3  NET_GEN3  UNIT_ID4  NET_GEN4  UNIT_ID5  NET_GEN5  UNIT_ID6  NET_GEN6
    11/1/2005 1:00:00 AM  5297      581       5298      318       5299      91        5300      59        5301      68        5302      45
    11/1/2005 2:00:00 AM  5297      625       5298      341       5299      97        5300      64        5301      74        5302      49etc
    We have a way of getting a "list" of the units related to each other. I just need a starting point of how to format the result set based on a variable number of units that might be grouped into a row.
    Thanks!

    Thanks for the info. I guess I now have a question on how do I make this work with passing the results back to .NET? The solution in that article creates an incompatible column type for ODP.NET v9.2.0.7
    The only solution I've been able to come up with is to create a collection type in the database. The problem with that is, it is a finite number of columns. I suppose I could make it big enough to hold some huge number of columns and only use what I want to, but that makes me cringe.
    I guess I'm trying to do something that is probably not possible without a lot of effor and headaches. The reason it's this way is because we have a client that wants us to display the data that way on a form, even though that is NOT how the data is layed out in the database.
    If anyone else has any suggestions, I would appreciate it. I'm about ready to go back to the cleitn and state that what they really have here is a parent/child relationship and that it would better to display it that way, even though it means they won't see 24 hours worth of data on the screen all at once without filling up the browser window.
    Thanks!

  • How to save data from JTable multiple rows and columns

    Hi Y_Not thanks for your help before...
    But what should I do if I want to get/save many data from many column and rows??

    i don't quite understand your (repeated) question. what is the problem with "multiple rows and columns". Y_NOT and i have shown you ways to access them.
    all you need are 2 loops: one around your number of rows and one around the number of columns or vice versa depending in which order you want to save things:
    for (int col = 0; col < data.size(); col++) {
        for (int row = 0 ; row < data[col].size(); row++) {
            // save your data
            saveData(data[col].getElementAt(row));
            // or use yourtable.getValueAt(row, col);
    }this is not a problem of Swing/Java but of simple algorithm...
    thomas

  • How to transpose the data records (rows) to column(lists) using apd

    Hi,
      how to transpose the data records (rows) to column (lists) using apd  in sap bw.
    I do not want to use abap routine.only use the transpose rows to list  transformation .
    Pls provide the step by step procedure .
    thanks,
    Nimai

    Save youe file to transpose as a csv and in the header row of your file for the columns you want to transpose you need to put some soer of a tag before the column name (ie your colum header was for a period budget will be something lie 2011001:ZFIBDD)
    1. You will need to create a new apd process (rsanwb)
    2. Insert a "Read from Data File" data source object and map it file (,csv)
    3. insert a transpose object into your apd process (middle row 4th one over in the transformations section)
    4. under the definition tab in the transformation object select all the columns that are to be transposed into rows and move them to the transformed area, the grouping fields section should contain the rows that you want to now be columns
    5.under the transformation tab enter in the seperator you selected  under the Field Name/Infoobject area (ie. ZFIBDD)
    6. under the details tab  you need to enter in all the fields to be transformed and tner the transposition field (ie ZFIBDD)
    7. Then you can insert a set of transformations and a DSO and link the newly transposed fields into that.
    hope that helps

  • How to convert a table data from rows to columns?

    Hi,
    I have a Employee table of the following format:
    Emp_id | Emp_name | Salary
    101 | James | 1000
    102 | Julia     | 2000
    I have to convert or transpose the table data as follows using a SQL statement/function -
    Emp_id | 101     |     102
    Emp_name | James |     Julia
    Salary     | 1000 |     2000
    How do I achieve this?
    Please help me.
    Thanks,
    993012
    Edited by: 993012 on Mar 11, 2013 3:26 AM

    993012 wrote:
    Hi Pavan,
    Thanks for the prompt reply.
    The link seems to be of not relevant to my question.
    My question is to clearly transpose the rows to columns and vice versa without any changes to data.
    Regards,
    993012I do not see any modification to the data in the Link posted by Pavan. Anyways, One catch with Transposing the Rows is, you need to know the Number of Columns you need to project.
    With Static SQL, there is no way to do so. Hence, you will need PL/SQL with Execute Immediate/Dynamic SQL.
    See demostration by Tom Kyte on Dynamic Pivots to have a look at the example and adapt to your situation.
    Although, I will debate on the need to do it in SQL. Because what you are upto is a part of Reporting and there are many reporting Tools which will have this functionality in-built. SQL, ideally should not be used for reporting purposes. It sole purpose it to store and pass the data to be rendered by Client Software i.e. Java or Third Party tools.

Maybe you are looking for

  • Error during deploying SOA Composite

    I have created a SOA Composite in which I am trying to access an External Web Service. The compilation goes fine but its failing at the time of deployment to Soa Server. My BPEL consists of following activities-> RecieveInput-> Assign -> Invoke -> As

  • Error in SM58 on XI box

    Hi, While trying to post IDocs to an R3 system, getting the following error in sm58 - 'Transactional RFC' transaction 'PASSWORD LOGON NO LONGER POSSIBLE'. But when I do a connection test from SM59, to the corresponding RFC destination listed in the r

  • How to make the KM Navigation iview role based

    Hi all, Can someone tell me how to make the KM navigation iview role based? First of all, is this possible? What I am trying to achive is display certain links for a user group and certain other links for another user group. Please guide me. Ashwini.

  • Install Error in InDesign CC

    InDesign shows an update error, which is why I uninstalled. Displays an error and it was not possible to install it in any way. What should I do?

  • All icons grayed out after sync or backup my ipad.

    Tried turn on and off restriction but does not help. Re-install itunes with the lastest windows version still same problem. With ipad2 on 4.3.3 and ipad1 on 5.01 same issue. Any suggestion?