How to get columns as rows

Hi everybody,
I have a table qualities with columns empno, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10. All the columns are number data type. The table has 10,000 records. How can i select each column as a different row for each empno.
Please help.
Thanks and regards
Sukanto

A couple of options might be something like...
SELECT
    EMPNO,
    1 AS QUANTITY_TYPE,
    Q1 AS QUANTITY
FROM
    YOUR_TABLE
UNION ALL
SELECT
    EMPNO,
    2 AS QUANTITY_TYPE,
    Q2 AS QUANTITY
FROM
    YOUR_TABLE
UNION ALL
SELECT
    EMPNO,
    3 AS QUANTITY_TYPE,
    Q3 AS QUANTITY
FROM
    YOUR_TABLE
UNION ALL
SELECT
    EMPNO,
    10 AS QUANTITY_TYPE,
    Q10 AS QUANTITY
FROM
    YOUR_TABLE...or...
WITH QUANTITY_TYPES AS
    SELECT 1 AS QUANTITY_TYPE FROM DUAL
    UNION ALL
    SELECT 2 AS QUANTITY_TYPE FROM DUAL
    UNION ALL
    SELECT 3 AS QUANTITY_TYPE FROM DUAL
    UNION ALL
    SELECT 10 AS QUANTITY_TYPE FROM DUAL
SELECT
    YOUR_TABLE.EMPNO,
    QUANTITY_TYPES.QUANTITY_TYPE,
    CASE QUANTITY_TYPES.QUANTITY_TYPE
        WHEN 1 THEN
            YOUR_TABLE.Q1
        WHEN 2 THEN
            YOUR_TABLE.Q2
        WHEN 3 THEN
            YOUR_TABLE.Q3
        WHEN 10 THEN
            YOUR_TABLE.Q10
    END AS QUANTITY
FROM
    YOUR_TABLE,
    QUANTITY_TYPES

Similar Messages

  • How to get number of rows return in SELECT query

    i'm very new in java, i have a question:
    - How to get number of rows return in SELECT query?
    (i use SQL Server 2000 Driver for JDBC and everything are done, i only want to know problems above)
    Thanks.

    make the result set scroll insensitve, do rs.last(), get the row num, and call rs.beforeFirst(), then you can process the result set like you currently do.
             String sql = "select * from testing";
             PreparedStatement ps =
              con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
             ResultSet rs = ps.executeQuery();
             rs.last();
             System.out.println("Row count = " + rs.getRow());
             rs.beforeFirst();~Tim
    NOTE: Ugly, but does the trick.

  • How to get column names for a specific view in the scheme?

    how to get column names for a specific view in the scheme?
    TIA
    Don't have DD on the wall anymore....

    or this?
    SQL> select text from ALL_VIEWS
      2  where VIEW_NAME
      3  ='EMP_VIEW';
    TEXT
    SELECT empno,ename FROM EMP
    WHERE empno=10

  • How to get a unique row in a value set

    How to get a unique row in a value set which is used in concurrent program.
    Example if a table contains 10 unique rows i need only one row to show.
    Thanks

    add conditions in where clause to supress the duplicate values.
    On how to supress the duplicate values follow the link
    http://oracleschools.com/index.php?topic=40.msg76#msg76
    Thanks
    Prudhvi
    www.erpschools.com

  • How to get count of rows for a table?

    Hi,
    How to get count of rows for a table and secondly, how can i have access to a particular cell in a table?
    Regards,
    Devashish

    Hi Devashish,
    WdContext.node<Your_node_name>().size() will give you the no: of rows.
    This should be the node that is bound to the table's datasource property.
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value); will select the row at that particular index.
    You can access an attribute of a particular row as
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value).get<attribute_name>();
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • How to get column header text in IWDTable

    Hi
    Just want to know how to get column header name in IWDTable.
    I know that you can get it with
    IWDAbstractTableColumn[] groupedColumns = table.getGroupedColumns();
    for (int i = 0; i < groupedColumns.length; i++) {
         IWDAbstractTableColumn column = groupedColumns<i>;
         column.getHeader().getText();
    But what if text isnt set on header level but its rendered from cellEditor  model binding (im not sure if its like that).

    Finally after your suggestion i did it with this code
    String header = column.getHeader().getText();
                       if ((header == null || header.length() == 0) && column instanceof IWDTableColumn){
                            IWDTableCellEditor tableCellEditor = ((IWDTableColumn) column).getTableCellEditor();
                            if (tableCellEditor instanceof IWDTextView){
                                 String bindingPath = ((IWDTextView)tableCellEditor).bindingOfText();
                                  StringTokenizer tokenizer = new StringTokenizer(bindingPath,".");
                                  String token = "";
                                  IWDNodeInfo nodeInfo = context.getNodeInfo();
                                  while (tokenizer.hasMoreTokens()){
                                       token = tokenizer.nextToken();
                                       if (tokenizer.hasMoreTokens()){
                                            nodeInfo = nodeInfo.getChild(token);          
                                  IWDAttributeInfo attribute = nodeInfo.getAttribute(token);
                                  ISimpleType simpleType = attribute.getSimpleType();
                                  simpleType.getDescription();
                                 header = simpleType.getDescription();

  • How to turn columns into rows

    Hi. Does anyone know how to turn columns into rows ie:
    select field1, field2, field3, field4, field5 from table
    desired result:
    field1 field2
    field1 field3
    field1 field4
    field1 field5
    Thank you!

    Something like this ?
    select field1
    , case n.l
    when 1 then field2
    when 2 then field3
    when 3 then field4
    when 4 then field5
    end field
    from table
    , (select level l from dual connect by level <= 4) n

  • How to freeze column and row headers of a table

    How to freeze column and row headers of a table in jsp and javascript. An example is available in
    http://www.massless.org/_tests/grid1/ pls help to find a solutionj
    Thanks in anticipation
    Sreejesh

    At least I don't stop you from that. I also don't see any benefits in this topic.
    Success.

  • Custom row-fetch and how to get column values from specific row of report

    Hi -- I have a case where a table's primary key has more than 3 columns. My report on the
    table has links that send the user to a single-row DML form, but of course the automatic
    fetch won't work because 1) I can't set more than 3 item values in the link and 2) the
    auto fetch only handles 2 PK columns.
    1)
    I have written a custom fetch (not sure it's the most elegant, see second question) that is working
    for 3 or few PK columns (it references the 1-3 item values set in the link), but when there are
    more than 3, I don't know how to get the remaining PK column values for the specific row that was
    selected in the report. How can I access that row's report column values? I'll be doing it from the
    form page, not the report page. (I think... unless you have another suggestion.)
    2)
    My custom fetch... I just worked something out on my own, having no idea how this is typically
    done. For each dependent item (database column) in the form, I have a source of PL/SQL
    function that queries the table for the column in question, using the primary key values. It works
    beautifully, though is just a touch slow on my prototype table, which has 21 columns. Is there
    a way to manually construct the fetch statement once for the whole form, and have APEX be smart
    about what items get what
    return values, so that I don't have to write PL/SQL for every item? Because my query data sources
    are sometimes in remote databases, I have to write manual fetch and dml anyway. Just would like
    to streamline the process.
    Thanks,
    Carol

    HI Andy -- Well, I'd love it if this worked, but I'm unsure how to implement it.
    It seems I can't put this process in the results page (the page w/ the link, that has multiple report rows), because the link for the row will completely bypass any after-submit processes, won't it? I've tried this in other conditions; I thought the link went directly to the linked-to page.
    And, from the test of your suggestion that I've tried, it's not working in the form that allows a single row edit. I tried putting this manually-created fetch into a before header process, and it seems to do nothing (even with a hard-coded PK value, just to test it out). In addition, I'm not sure how, from this page, the process could identify the correct PK values from the report page, unless it can know something about the row that was selected by clicking on the link. It could work if all the PK columns in my edit form could be set by the report link, but sometimes I have up to 5 pk columns.
    Maybe part of the problem is something to do with the source type I have for each of the form items. With my first manual fetch process, they were all pl/sql functions. Not sure what would be appropriate if I can somehow do this with a single (page level?) process.
    Maybe I'm making this too hard?
    Thanks,
    Carol

  • How to get a single row column from a viewobject in java?

    I have a class file that goes out and gets a viewobject and sets its where clause
    this is it:
    vcRow = vc.createViewCriteriaRow();
    vcRow.setAttribute("LogonId", "='" + strPcis_Login.toUpperCase() + "'");
    vc.addElement(vcRow);
    vo.applyViewCriteria(vc);
    vo.executeQuery();
    I know this working cause I can watch it in debug..
    but now the problem.
    I've looked in the docs and don't see how one can pull the value of the row it found and place it in a uix page in a textinput area
    how can I get a single row column, in this case the UserName that is in the view object to a string and then place it into my
    uix page? I've looked and looked and don't see a method for this.
    is there a way to take the oracle.cabo.servlet.Page and set a textinput with a viewobject get method?
    what way do you do this and where is it documented?

    is there a way to take the oracle.cabo.servlet.Page and set a textinput with a viewobject get method?
    what way do you do this and where is it documented? What you can do is get the value from your VO and set it somewhere that UIX can data bind to -- as a Page proprety, on HttpSession, etc. This is documented in Chapters 4 (Data Binding) and 5 (Controller) of the UIX Developer's Guide.
    To set a property, you use Page.setProperty(String key, String value). Then, in your UIX file, to make a textInput that has the value pulled from a given page property, use:
    <textInput data:text="key@ctrl:page" />
    -brian
    Team UIX

  • How to get the selected rows & columns in the table?

    hi everybody,
                         In my application the table is kept inside the event structure.I select the cells  in the table (using mouse) on running time.How to get the selected number of rows & columns in that table?

    Hello,
    You can fill selected values of the table by writing to it or the corresponding property using a property node - the table is just a 2D array of strings.  I think for your "disable" question you are referring to the shortcut menu (when you right click).  If you are using LabVIEW 8.x, you can edit or disable that shortcut menu - just right click on your table at edit time and choose Advanced >> Run-Time Shortcut Menu.
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Check box als column in a standard table, how to get the selected row

    Dear experts,
    I habe standard tablt with check box as column. Now I want to get the current selected row structure and do some changes. How could I solve this problem? till now I just know to get the structure via lead selection.
    lo_node->get_element().
    lo_element = lo_node->get_static_attributes ( static_attributes = ls_row).
    How could I get the element through check-box in stead of lead selection. Many thanks!

    check this code
    To get the selected row number
    data: lr_element type ref to if_wd_context_element,
              lv_index type i.
      lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT'  ).
      lv_index = lr_element->get_index( ).
    Thanks
    Bala Duvvuri

  • How to get number of rows and columns in a two dimensional array ?

    Hello,
    What would be the simplest way to get number of rows and columns in a two dimensional array represented as integers ?
    I'm looking for another solution as For...Each loop in case of large arrays.
    Regards,
    Petri

    Hi Petri,
    See a attached txt file for obtaining two arrays with upper and lower index values
    Regards
    Ray
    Regards
    Ray Farmer
    Attachments:
    Get2DArrayIndex.txt ‏2 KB

  • How to get column value from DB grid

    Hi!
    I wander how to get col value from GridControl?
    My app consists of one rowsetinfo with two
    columns CODE and DESCRIPTION and a jbutton
    titled SELECT. When user clicks SELECT button
    the app should show the value of the CODE col
    of the selected row in GridControl.
    I wander how to make this action ?
    XxpsTransTimesMasterIter.setAttributeInfo( new AttributeInfo[] {
    CODEXxpsTransTimesMasterIter,
    DESCRIPTIONXxpsTransTimesMasterIter} );
    XxpsTransTimesMasterIter.setName("XxpsTransTimes");
    XxpsTransTimesMasterIter.setQueryInfo(new QueryInfo(
    "XxpsTransTimesMasterIterViewUsage",
    "lov.XxpsTransTimes",
    "CODE, DESCRIPTION",
    "XXPS_TRANS_TIMES",
    null,
    null
    ));

    Hi,
    You could attach an ActionListener on the JButton, and try the following code :
    NavigationManager fm = NavigationManager.getNavigationManager();
    DataItem dataItem = fm.getFocusedControl().getDataItem();
    ImmediateAccess col_code = null;
    String code = null;
    if (dataItem != null && dataItem instanceof RowsetAccess) {
    RowsetAccess rowset = (RowsetAccess)dataItem;
    try {
    col_code = (ImmediateAccess) rowset.getColumnItem("CODE");
    code = col_code.getValueAsString();
    } catch (DuplicateColumnException de) {
    return;
    } catch (ColumnNotFoundException ce) {
    return;
    } catch (SQLException se) {
    return;
    JTextField tf = new JtextField();
    tf.setText(code);
    I haven't tested this code.
    I am curious to know, the Object type of the dataItem.If it doesnot happen to be RowsetAccess ..try.. ScrollableRowsetAccess OR ImmediateAccess.
    Your code would change accordingly, depending on the instance.Refer to the product documentation for this.
    Do let me know, if this works.
    TIA
    Sandeep

  • How to get columns horizontal in pl/sql procedure

    My task is I want to retrieve all the Insert Statements of the rows that are present in each table of a particular Schema.
    When I give input as Schema name(Scott) in a Procedure, Then the procedure retrieves all the Insert statements of rows of all tables that are present in scott user.
    For this I started like this
    CREATE OR REPLACE PROCEDURE MYPROC(UID DBA_OBJECTS.OWNER%TYPE)
    AS
    CURSOR MYCUR IS select o.owner, o.object_name,c.column_name
    from dba_objects o, dba_tab_cols c where o.owner=c.OWNER(+) AND O.OWNER=UID
    AND O.OBJECT_NAME=C.TABLE_NAME AND ROWNUM<20 AND O.OBJECT_TYPE='TABLE';
    BEGIN
    FOR EREC IN MYCUR LOOP
    DBMS_OUTPUT.PUT_LINE('insert into '||erec.object_name||'('||erec.column_name||')'||'values(');
    END LOOP;
    END MYPROC;
    When I execute this procedure I got the result as follows.
    EXEC MYPROC('SCOTT');
    insert into DEPT(DEPTNO)values(
    insert into DEPT(DNAME)values(
    insert into DEPT(LOC)values(
    insert into EMP(EMPNO)values(
    insert into EMP(ENAME)values(
    insert into EMP(JOB)values(
    insert into EMP(MGR)values(
    insert into EMP(HIREDATE)values(
    insert into EMP(SAL)values(
    insert into EMP(COMM)values(
    insert into EMP(DEPTNO)values(
    insert into BONUS(ENAME)values(
    insert into BONUS(JOB)values(
    insert into BONUS(SAL)values(
    insert into BONUS(COMM)values(
    insert into SALGRADE(GRADE)values(
    insert into SALGRADE(LOSAL)values(
    insert into SALGRADE(HISAL)values(
    insert into PROJECT(PNO)values(
    As you see the columns are coming in line by line.
    Now My question is I want the columns of each table to come in only One Insert Statement.i.e. one insert statement for one table. All columns of one table should in one row. How to do this?
    Please Help me
    Thanks in Advance.

    Hi,
    two loops works the easiest way
    CREATE OR REPLACE PROCEDURE MYPROC(UID DBA_OBJECTS.OWNER%TYPE)
    AS
    CURSOR MYtab
    IS
    select o.owner, o.object_name
    from dba_objects o where O.OWNER=UID
    and ROWNUM<20
    AND O.OBJECT_TYPE='TABLE';
    CURSOR MYCol(b_owner varchar2,b_table varchar2)
    IS
    select c.column_name
    from dba_tab_cols c where c.owner=b_OWNER AND b_table=C.TABLE_NAME;
    l_line varchar2(2000);
    begin
      for r_tab in mytab
    loop
      l_line :='insert into '||r_tab.object_name||'(');
      for r_col in mycol(r_tab.owner,r_tab.object_name)
      loop
        l_line := l_line||r_col.column_name||',';
      end loop;
      l_line := rtrim(l_line,',')||') values (';
    dbms_output.put_line(l_line);
    end loop;
    end;Hope this will give you some insights how to get the results.
    Herald ten Dam
    Superconsult.nl

Maybe you are looking for

  • App World not responding :(

    Tried to open the appworld app, but it just goes in circles and then returns back with app world not responding. There is a problem with appworld. Tried Software Update, it says the update server is temporarily unavailable. error code 2032.

  • Shooting a school play, camera advice

    Hi, We have been asked by the school if we could shoot this years Christmas play. We thought the best way was to setup 3 fixed cameras covering different angles of the stage and use Final Cut Pro to cut the footage together. We would ideally like to

  • Error connecting in Discoverer Plus/Viewer 10.1.2

    I'm triying to connect to Discoverer Plus or Viewer. When I get to the login screen, fill all the required fields, but I got the following message: "The application encountered an invalid state. - - Nested exception: org.omg.CORBA.COMM_FAILURE: vmcid

  • VA21 - Quotation from service order with reference to an inquiry

    Dear Guru, I am trying to create a quotation using VA21 with reference to an Inquiry (IN) I have previously created. The inquiry number is: 10000004 There I have the following error message: "Copying from sales document AE to IN is not supported" Can

  • New Joe Bonamassa album

    I recently purchased the new Joe Bonamassa album on iTunes however when I try to copy it to my iPhone 4S it will not copy. I get a message saying the file did not copy because it cannot be played on this iPhone. Does anyone know what is going on?