How to rearrange the structure of a table by using a view?

At wits end: I need to reorganize the structure of a table into a new structure - either as a view or actually moving the data from the old structure to the new structure (using a view).
The old structure is:
TESTNAME, SCHOOL_ID, PTILE1, PTILE2, PTILE3 ... PTILE99
Test1,0001,18,19,20...
Test1,0002,23,24,28...
Test1,0003,20,21,26...
Test2,0001,48,52,55...
Test2,0002,50,54,54...
Test2,0003,60,62,64
The new structure is:
SCHOOL_ID,PTILE,TESTNAME1,TESTNAME2...
1,0001,Score1,Score2...
1,0002,Score1,Score2...
1,0003,Score1,Score2...
2,0001,Score1,Score2...
2,0002,Score1,Score2...
2,0003,Score1,Score2...
99,0001,Score1,Score2...
99,0002,Score1,Score2...
99,0003,Score1,Score2...
What this data shows are the percentiles for test scores for different tests for each school who took the tests.
It seems like creating a view to arrange the data through a bunch of selects and unions would work, but I can't figure out how.

Tricky.
When confronted with a problem like this I try to write out an algorthm in pseudocode to work out what I want to do. If you have more than 2 or 3 tables to merge I'd consider going with a new structure; otherwise the view approach might be a good idea. Remember that if you go with a new structure you can insert once and update the other values later, something like
foreach school insert row
update testname1
update testname2
Good luck.

Similar Messages

  • How to compare the structure of multiple tables ..have only TOAD & PUTTY

    Hi,
    Many times i get a request to load some tables' data from one schema to another . But before doing that i need to compare the structures of the tables in the source & target schema.
    How can i do that? The list of tables keep on changing every now & then. In TOAD there is no option to compare a selected list of tables. Comparing the whole schemas is not a option before me as the schemas are too huge and it takes a lot of time to do the schema level comparision.
    Note this is a client machine and we are not allowed to install any s/w.
    I am working on making a unix script which does that for me. But that may take some time considering the hectic work schedule and my poor knowledge of unix scripting.
    Can someone suggest some way to do it?
    Regds,
    Kunwar

    i need to compare the structures of the tables in the source & target schema.SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'SOURCE'
    MINUS
    SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'TARGET'
    UNION
    SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'TARGET'
    MINUS
    SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'SOURCE'

  • How to delete the records from database table without using work area

    Hi all,
    The purpose of the down program is to delete the entire contents from all the tables. The deletion of the table should be in sorted manner. Is there any other way to write the code more efficiently,
    TABLES: ZFFMCTL_AP, ZFFMHDR_AP, ZFFM_CHANGE_LOG, ZFFMDTL_AR, ZFFMHDR_AR, ZFFMDTL_JV, ZFFMHDR_JV, ZFFMDTL_SKF,ZFFMHDR_SKF,ZFINVOICE_DETAIL, ZFFMMASTER, ZFFMLOGREAD_CLUS, ZFFMCTL.
    DELETE ZFFMCTL_AP.
    IF SY-SUBRC = 0.
    DELETE ZFFMMHDR_AP.
    IF SY-SUBRC = 0.
    DELETE ZFFM_CHANGE_LOG.
    IF SY-SUBRC = 0.
    DELETE ZFFMDTL_AR.
    IF SY-SUBRC = 0.
    DELETE ZFFMHDR_AR.
    IF SY-SUBRC = 0.
    DELETE ZFFMDTL_JV.
    IF SY-SUBRC = 0.
    DELETE ZFFMHDR_JV.
    IF SY-SUBRC = 0.
    DELETE ZFFMDTL_SKF.
    IF SY-SUBRC = 0.
    DELETE ZFFMHDR_SKF.
    IF SY-SUBRC = 0.
    DELETE ZFINVOICE_DETAIL.
    IF SY-SUBRC = 0.
    DELETE ZFFMMASTER.
    IF SY-SUBRC = 0.
    DELETE ZFFMLOGREAD_CLUS.
    IF SY-SUBRC = 0.
    DELETE ZFFMCTL.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    Waiting for response,
    Thanks in advance
    John

    Write this way....
    TABLES: ZFFMCTL_AP, ZFFMHDR_AP, ZFFM_CHANGE_LOG, ZFFMDTL_AR, ZFFMHDR_AR, ZFFMDTL_JV, ZFFMHDR_JV, ZFFMDTL_SKF,ZFFMHDR_SKF,ZFINVOICE_DETAIL, ZFFMMASTER, ZFFMLOGREAD_CLUS, ZFFMCTL.
    DELETE ZFFMCTL_AP.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMMHDR_AP.
    CHECK SY_SUBRC = 0.
    DELETE ZFFM_CHANGE_LOG.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMDTL_AR.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMHDR_AR.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMDTL_JV.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMHDR_JV.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMDTL_SKF.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMHDR_SKF.
    CHECK SY_SUBRC = 0.
    DELETE ZFINVOICE_DETAIL.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMMASTER.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMLOGREAD_CLUS.
    CHECK SY_SUBRC = 0.
    DELETE ZFFMCTL.

  • How to identify the hidden columns in table by using af:panelCollection

    Hi,
    We are using af:panelCollection tag for a table to show personalization features. i.e. to hide or disaply colums in the table.
    We also have a print button to print data in the table. the issue is when we hide any column in teble using the personalization feature given by af:panelCollection , we can see the hidden columns also on the page to be printed.which should not happen.
    For printing table we cant use showPrintablePageBehavior coz it prints data on current page only where as we also have Print all data button which should print all data on table which is not visible on scrren due to pagination.
    Using ADF 11.1.1.5.0 and JSF 2.0 . Please help how to capture whci colums are made hidden.
    The code used for printing data is
    <div class="print_data">Print Current Data</div>
    <ahref="printCurrentData.jsp" target="_blank" class="left">
    <img src="print.png" alt="abc"
    width="24" height="22" border="0"/></a>
    <div class="print_data">Print All Data</div>
    <ahref="printAllData.jsp" target="_blank" class="left">
    <img src="print.png" alt="abc"/></a>
    Edited by: 924834 on Aug 27, 2012 4:27 AM
    Edited by: 924834 on Aug 27, 2012 4:28 AM

    There are some things which don't add up here.
    You are using jdev 11.1.1.5.0 which only comes with jsf 1.2, but you are using jsf 2.0?
    Then you are using jsp instead of jsf which are the normal way to go for jsf.
    Can you please clarify on this?
    How is the printCurrentData.jsp setup? Do you have a table on it based on the same iterator as on the visible page with the hidden column?
    Timo

  • How to know the last time a table was used?

    I was trying to find a log or something that can tell me when and who was the last one/s that used a table.
    Could someone help me?
    thanks

    How can I activate the auditing? http://download-east.oracle.com/docs/cd/B19306_01/network.102/b14266/auditing.htm#i1011984
    Daljit Singh

  • How to know the size of a table by using sql command?

    i've got a question that i hope to know a table size by using sqlcommand?
    what to do?
    thanks in advice,

    Select sum(bytes) bytes, sum(blocks) blocks
    from dba_segments
    where segment_name = 'YOUR_TABLE';This will give you the space in the database allocated to the table. If you want to know the actual space it takes up then you'll have to analyze the table and interrogate the stats using DBA_TABLES.
    APC

  • How to determine the slew rate of an amplifier using lab view

    gud evening all
    I have an op amp circuit built on the NI ELVIS board and I input a square wave from function generator to the circuit. I have to determine the slew rate of the op amp.In the labs, one would run the square wave over a range of frequencies and stop when the square wave looks like a triangular wave. At that frequency, one would then measure the slope of the signal and that will give you the slew rate. How can I do that in LabVIEW? How can I check when my square wave starts looking like a triangular wave? please help
    good
    good

    thank you johnsold
    i designed a voltage follower using 741, on an Ni elvis instrument. i can manually do the slew rate experiment by varying the frequency range on the coasre frequency knob( using a square wave) of the function generator until the slew rate occurs at 0.5volts, my problem is how can i do the same experiment with built in vi in labview with out touching the knob on the function generator and once the triangular wave starts to show the lab view program will automatically stop.
    find attache my vi
    good
    Attachments:
    slew rate.vi ‏21 KB

  • Copy the structure of a table to another with another table name.

    how to copy the structure of a table to another with another table name.
    ie. i want a emp table with same values/structure to be copied to another table called my_employee.
    how can this be done?

    create table my_emp as select * from emp;
    If you do not want the data to be copied then do the following:
    create table my_emp as select * from emp
    where 1=2;
    Avanti.

  • How to find the structural difference between two tables

    Hi all,
    How to find the structural difference between two tables .
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thanks,
    P Prakash

    you could try something similar to this, for each table pair that you want to compare:
    SELECT 'TABLE_A has these columns that are not in TABLE_B', DIFF.*
      FROM (
            SELECT  COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_A'
             MINUS
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_B'
          ) DIFF
    UNION
    SELECT 'TABLE_B has these columns that are not in TABLE_A', DIFF.*
      FROM (
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_B'
             MINUS
            SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
              FROM all_tab_columns
             WHERE table_name = 'TABLE_A'
          ) DIFF;that's assuming, column_name, data_type and data_length are all you want to compare on.

  • How to find the structure fields data in database tables?

    how to find the structure fields data in database tables?

    Your question doesn't appear to be Web Dynpro ABAP related. Please only post questions in this forum if they are directly Web Dynpro ABAP related.  There are several other more general ABAP related forums.

  • How to get the StatusText from XMII_JCOMESSAGES Table

    Hi all,
    I need to show the Status as well as StatusText from XMII_JCOMESSAGES table for a particular message in a custom User Interface. I have checked through Read Message action block and Query Message action block. Read Message action block returns two XML structure like JCOMessage and MessageDocumentXML. JCOMessage xml does not contain the StatusText field. The structure of JCOMessage is like
    <JCOMessage>
    <MessageId/>
    <JcoServerName/>
    <MessageName/>
    <Category/>
    <MessageType/>
    <Status/>
    <DocNumber/>
    <DocCount/>
    <Function/>
    <PacketID/>
    <ProcessingTimeStamp/>
    <ReceivedTime/>
    </JCOMessage>
    But I have checked the XMII_JCOMESSAGES table from NWA  and the structure of XMII_JCOMESSAGES table is
    MESSAGEID
    RECEIVEDDATETIME
    JCOSERVERID
    MESSAGETYPE
    MESSAGENAME
    PROCESSINGDATETIME
    DOCNUMBER
    DOCXML
    CATEGORY
    PACKETID
    STATUS
    STATUSTEXT
    SERVER
    So, how can I fetch the STATUSTEXT field. Can anybody help me.
    Thanks in advance
    Chandan

    Aside from the Update Message block status text (integer values 1 - 4 coincide with the options in the drop down box on the configure dialog) that you can see in the link editor, you may need to use the Message Monitor status flag on the web page to determine what the number means in relation to friendly status text.
    Probably worth logging a ticket for consideration to add this into the actions.  I would assume this string might be translated into a local languague for the user but I'm not sure.

  • How to delete the data from partition table

    Hi all,
    Am very new to partition concepts in oracle..
    here my question is how to delete the data from partition table.
    is the below query will work ?
    delete from table1 partition (P_2008_1212)
    we have define range partition ...
    or help me how to delete the data from partition table.
    Thanks
    Sree

    874823 wrote:
    delete from table1 partition (P_2008_1212)This approach is wrong - as Andre pointed, this is not how partition tables should be used.
    Oracle supports different structures for data and indexes. A table can be a hash table or index organised table. It can have B+tree index. It can have bitmap indexes. It can be partitioned. Etc.
    How the table implements its structure is a physical design consideration.
    Application code should only deal with the logical data structure. How that data structure is physically implemented has no bearing on application. Does your application need to know what the indexes are and the names of the indexes,in order to use a table? Obviously not. So why then does your application need to know that the table is partitioned?
    When your application code starts referring directly to physical partitions, it needs to know HOW the table is partitioned. It needs to know WHAT partitions to use. It needs to know the names of the partitions. Etc.
    And why? All this means is increased complexity in application code as this code now needs to know and understand the physical data structure. This app code is now more complex, has more moving parts, will have more bugs, and will be more complex to maintain.
    Oracle can take an app SQL and it can determine (based on the predicates of the SQL), which partitions to use and not use for executing that SQL. All done totally transparently. The app does not need to know that the table is even partitioned.
    This is a crucial concept to understand and get right.

  • How to retrieve the values from a table if they differ in Unit of Measure

    How to retrieve the values from a table if they differ in Unit of Measure?

    If no data is read
    - Insure that you use internal code in SELECT statement, check via SE16 desactivating conversion exit on table T006A. ([ref|http://help.sap.com/saphelp_nw70/helpdata/en/2a/fa0122493111d182b70000e829fbfe/frameset.htm])
    If no quanity in result internal table
    - There is no adqntp field in the internal table, so no quantity is copied in itab ([ref|http://help.sap.com /abapdocu_70/en/ABAPINTO_CLAUSE.htm#&ABAP_ALTERNATIVE_1@1@]).
    - - Remove the CORRESPONDING, so quantity will fill the first field adqntp1.  ([ref|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_WA.htm])
    - - Then loop at the internal table and move the quantity when necessary to the 2 other fields.
    * Fill the internal table
    SELECT msehi adqntp
      INTO TABLE internal table
      FROM lipso2
      WHERE vbeln = wrk_doc1
        AND msehi IN ('KL','K15','MT').
    * If required move the read quantity in the appropriate column.
    LOOP AT internal_table ASSIGNING <fs>.
      CASE <fs>-msehi.
        WHEN 'K15'.
          <fs>-adqnt2 = <fs>-adqnt1.
          CLEAR <fs>-adqnt1.
        WHEN 'MT'.
          <fs>-adqnt3 = <fs>-adqnt1.
          CLEAR <fs>-adqnt1.
      ENDCASE.
    ENDLOOP.
    - You could also create another table with only fields msehi and adqntp and then collect ([ref|http://help.sap.com/abapdocu_70/en/ABAPCOLLECT.htm]) the data to another table.
    Regards,
    Raymond

  • How to get the data from Pooled Table T157E.

    Hi Experts,
    How to get the data from Pooled Table T157E.
    Any help.
    Thanks in Advance,
    Ur's Harsha.

    create some internal table similar to T157E and pass all data as per SPRAS.
    After that use internal table in your program as per the requirement.
    Regds,
    Anil

  • How to hide the data in particular table in oracle 10g

    How to hide the data in particular table in oracle 10g
    i want steps

    If its on Report u can  always hide the column - Keyfigure or Selection - Display - Hide......y do u want to have it on the report if it is to be hided in the first place?

Maybe you are looking for