A view from a table.. with cursors?

i have a table with this:
contract - date de execução - action
3034 - 01012006 -72
3034 - 10022006 -73
2011 - 05012006 -74
2011- 10012006 -73
and I want a view with this:
3034 - 01012006 - 72 - 10022006 - 73
2011 - 05012006 - 74 - 10012006 - 73
how can I extract this fastly?
thanks

There can be too many interpretations of your data and what you want to get -
do you want for example to have last and first values amongth particular group
ordered by date - for example:
SQL> select * from t order by 1,2;
CONTRACT   DATE#            ACTION
2011       05012006             74
2011       07012006             70
2011       10012006             73
3034       01012006             72
3034       05012006             71
3034       10022006             73
6 rows selected.
SQL> select unique contract,
  2  first_value(date#) over(partition by contract order by date#) date1,
  3  first_value(action) over(partition by contract order by date#) action1,
  4  last_value(date#) over(partition by contract order by date#
  5  range between unbounded preceding and unbounded following) date2,
  6  last_value(action) over(partition by contract order by date#
  7  range between unbounded preceding and unbounded following) action2
  8  from t
  9  /
CONTRACT   DATE1           ACTION1 DATE2           ACTION2
2011       05012006             74 10012006             73
3034       01012006             72 10022006             73Please, make your task clear.
Rgds.

Similar Messages

  • How to select all the colomns_names from a table, with their datatypes ..

    hi :)
    i would like to know, how to select in SQL all the columns names from a table with their datatypes so that i get something like this :
    Table 1 : table_name
    the column ID has the Datatype NUMBER
    the column name has the Datatype Varchar2
    Table 2 : table_name
    the column check has the Datatype NUMBER
    the column air has the Datatype Varchar2
    and that has to be for all the tables that i own ! ..
    P. S : i m trying to do this with java, so it s would be enough if you just tell me how to select all the tables_names with all their colums_names and with all their datatypes ! ..
    thank you :)
    i ve heard it can be done with USER_TABLES .. but i have no idea how :( ..
    Edited by: user8865125 on 17.05.2011 12:22

    Hi,
    The data dictionary view USER_TAB_COLUMNS has one row for every column in every table in your schema. The columns TABLE_NAME, COLUMN_NAME and DATA_TYPE have all the information you need.
    Another data dictionary view, USER_TABLES, may be useful, too. It has one row pre table.

  • Reading Data from a Table With an Expert

    Hi all - I'm trying to write an Expert in OWB that would read data from a table and create a new table based on that information. I have the table creation part down, but how can I read data from a table with an Expert? From what I've read, Experts only deal with metadata, and there is no mechanism in Experts to actually read data in the tables. Does OraTcl work in Experts? Has anyone ever came across this problem, and if so, how did you solve it? Thanks in advance for your time! - Don

    Hi Don
    Can also use Java and JDBC from within Tcl, see the routines in this file below, take modify or whatever;
    http://blogs.oracle.com/warehousebuilder/ombora.tcl
    source <dir>\ombora.tcl
    set g_user scott
    set g_upwd zzzzzz
    set g_hostname localhost
    set g_port 1521
    set g_srvname ora111
    oraconnect $g_user $g_upwd $g_hostname:$g_port:$g_srvname
    oraselect "select * from emp" ""
    As well as dumping the results to stdout (you probably want to comment that part out and change any other part you don't like), g_res is a ResultSet object you can use to do whatever.
    Cheers
    David

  • Cartesian of data from two tables with no matching columns

    Hello,
    I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
    I am thinking about something like:
    for $COUNTRY in ns0: COUNTRY ()
    for $PROD in ns1:PROD()
    return <Results>
         <COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
         <PROD> {fn:data($PROD/PROD_NAME)} </PROD>
    </Results>
    And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
    What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
    What I’ve noticed also is that when I add something like:
    where COUNTRY_NAME != PROD_NAME
    everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
    So the question is – what’s the suggested approach for such queries?
    Thanks,
    Leszek
    Edited by xnts at 11/19/2007 10:54 AM

    Which in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
    Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
    If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so.

  • Select max date from a table with multiple records

    I need help writing an SQL to select max date from a table with multiple records.
    Here's the scenario. There are multiple SA_IDs repeated with various EFFDT (dates). I want to retrieve the most recent effective date so that the SA_ID is unique. Looks simple, but I can't figure this out. Please help.
    SA_ID CHAR_TYPE_CD EFFDT CHAR_VAL
    0000651005 BASE 15-AUG-07 YES
    0000651005 BASE 13-NOV-09 NO
    0010973671 BASE 20-MAR-08 YES
    0010973671 BASE 18-JUN-10 NO

    Hi,
    Welcome to the forum!
    Whenever you have a question, post a little sample data in a form that people can use to re-create the problem and test their ideas.
    For example:
    CREATE TABLE     table_x
    (     sa_id          NUMBER (10)
    ,     char_type     VARCHAR2 (10)
    ,     effdt          DATE
    ,     char_val     VARCHAR2 (10)
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0000651005, 'BASE',    TO_DATE ('15-AUG-2007', 'DD-MON-YYYY'), 'YES');
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0000651005, 'BASE',    TO_DATE ('13-NOV-2009', 'DD-MON-YYYY'), 'NO');
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0010973671, 'BASE',    TO_DATE ('20-MAR-2008', 'DD-MON-YYYY'), 'YES');
    INSERT INTO table_x (sa_id,  char_type, effdt,                          char_val)
         VALUES     (0010973671, 'BASE',    TO_DATE ('18-JUN-2010', 'DD-MON-YYYY'), 'NO');
    COMMIT;Also, post the results that you want from that data. I'm not certain, but I think you want these results:
    `    SA_ID LAST_EFFD
        651005 13-NOV-09
      10973671 18-JUN-10That is, the latest effdt for each distinct sa_id.
    Here's how to get those results:
    SELECT    sa_id
    ,         MAX (effdt)    AS last_effdt
    FROM      table_x
    GROUP BY  sa_id
    ;

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • Materialized view from prebuilt table doesn't work with spatial types?

    Hello, I'm trying to build a materialized view of a table using the prebuilt option and a pre-built table.
    Oracle gives me an ORA-32304 error, saying it can't do this with user-defined types. The original table has no user-defined types, but does use an sdo_geometry column. Is this what it's complaining about?
    Now I can sort of understand this, but here's my real problem: the materialized view I'm creating is comprised of a subset of the columns from the original table, but not the geometry column. Is Oracle right in refusing my prebuilt request? Does anyone know of a way around this (besides creating the MV from scratch without prebuilt).
    I've successfully created an MV on another table, which doesn't have a spatial column, using the prebuilt option and a subset of columns.
    (I'm using Oracle 11.2.0.2.0 on both master and slave databases)

    Good news, everyone! =)
    SAPwebIDE team fixed this issue with MMD template in SAPwebIDE v1.10.2. available on http://hanatrial.ondemand.com.
    This "Bug" or "Feature" was presented in 1.8.x and 1.9.x SAPwebIDE (i've used local installation) and now it's gone in v1.10.2. Thank you, SAPwebIDE Team! =)
    The difference between versions of MMD template is only in one file (fixed one is on the right):
    Master2.controller.js
    And here it is:
    Now, only one question remains: HOWTO:SAPUI5 Fiori-like report. (mix control's value as key into binding context)
    Best regards, ilia.

  • Issue in retrieving all the records from ADF Table with multiple row

    Hi,
    As per my requirement, I need to fill the table with multi selected LOV values and when user clicks on commit, I need to save them to database.
    I am using ADF 11g, Multi select table. Using the below ADD method, I am able to add the records but if user clicks on cancel, I need to remove those from view and clear the table as well.
    But the Issue I am facing is, in my cancel method, always I am getting half of the records. Lets assume table contains 100 records but in my cancel method, I am getting only 50 records.
    Please let me know what is the issue in my source code.
    ADD Method:
    public void insertRecInCMProcessParamVal(String commType, String processType, Number seqNumber){       
    try{
    Row row = this.getCmProcessParamValueView1().createRow();
    row.setAttribute("ParamValue7", commType);
    row.setAttribute("ProcessType", processType);
    row.setAttribute("CreationDate", new Date());
    row.setAttribute("CreatedBy", uid);
    row.setAttribute("ParamValueSeqNum", seqNumber);
    row.setAttribute("ProcessedFlag", "N");
    this.getCmProcessParamValueView1().insertRow(row);
    }catch(Exception e){           
    e.printStackTrace();
    Table Code:
    <af:table value="#{bindings.CmProcessParamValueView11.collectionModel}"
    var="row"
    rows="#{bindings.CmProcessParamValueView11.rangeSize}"
    emptyText="#{bindings.CmProcessParamValueView11.viewable ? 'No data to display.' : 'Access Denied.'}"
    fetchSize="#{bindings.CmProcessParamValueView11.rangeSize}"
    rowBandingInterval="1"
    selectedRowKeys="#{bindings.CmProcessParamValueView11.collectionModel.selectedRow}"
    selectionListener="#{bindings.CmProcessParamValueView11.collectionModel.makeCurrent}"
    rowSelection="multiple"
    binding="#{backingBeanScope.backing_app_RunCalcPage.t1}"
    id="t1" width="100%" inlineStyle="height:100px;" >
    <af:column sortProperty="ParamValue6"
    sortable="true"
    headerText="#{bindings.CmProcessParamValueView11.hints.ParamValue6.label}"
    id="c1" visible="false">
    <af:inputText value="#{row.bindings.ParamValue6.inputValue}"
    label="#{bindings.CmProcessParamValueView11.hints.ParamValue6.label}"
    required="#{bindings.CmProcessParamValueView11.hints.ParamValue6.mandatory}"
    columns="#{bindings.CmProcessParamValueView11.hints.ParamValue6.displayWidth}"
    maximumLength="#{bindings.CmProcessParamValueView11.hints.ParamValue6.precision}"
    shortDesc="#{bindings.CmProcessParamValueView11.hints.ParamValue6.tooltip}"
    id="it3">
    <f:validator binding="#{row.bindings.ParamValue6.validator}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="ParamValue7"
    sortable="true"
    headerText="Comm Type"
    id="c2">
    <af:inputText value="#{row.bindings.ParamValue7.inputValue}"
    label="#{bindings.CmProcessParamValueView11.hints.ParamValue7.label}"
    required="#{bindings.CmProcessParamValueView11.hints.ParamValue7.mandatory}"
    columns="#{bindings.CmProcessParamValueView11.hints.ParamValue7.displayWidth}"
    maximumLength="#{bindings.CmProcessParamValueView11.hints.ParamValue7.precision}"
    shortDesc="#{bindings.CmProcessParamValueView11.hints.ParamValue7.tooltip}"
    id="it4">
    <f:validator binding="#{row.bindings.ParamValue7.validator}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="ParamValue8"
    sortable="true"
    headerText="#{bindings.CmProcessParamValueView11.hints.ParamValue8.label}"
    id="c3" visible="false">
    <af:inputText value="#{row.bindings.ParamValue8.inputValue}"
    label="#{bindings.CmProcessParamValueView11.hints.ParamValue8.label}"
    required="#{bindings.CmProcessParamValueView11.hints.ParamValue8.mandatory}"
    columns="#{bindings.CmProcessParamValueView11.hints.ParamValue8.displayWidth}"
    maximumLength="#{bindings.CmProcessParamValueView11.hints.ParamValue8.precision}"
    shortDesc="#{bindings.CmProcessParamValueView11.hints.ParamValue8.tooltip}"
    id="it2">
    <f:validator binding="#{row.bindings.ParamValue8.validator}"/>
    </af:inputText>
    </af:column>
    </af:table>
    Backing Bean Code:
    DCBindingContainer dcBindings=(DCBindingContainer)getBindings();
    DCIteratorBinding dcIterator=dcBindings.findIteratorBinding("CmProcessParamValueView1Iterator");
    RowSetIterator rs = dcIterator.getRowSetIterator();
    System.out.println("In Cancel Row Count is : "+ rs.getRowCount());
    if (rs.getRowCount() > 0) {
    Row row = rs.first();
    row.refresh(Row.REFRESH_UNDO_CHANGES);
    row.remove();
    while (rs.hasNext()) {
    int count = rs.getRowCount();
    System.out.println("Count is : "+ count);
    Row row = rs.next();
    System.out.println("Row === "+ row);
    if(row != null){                   
    row.refresh(Row.REFRESH_UNDO_CHANGES);
    row.remove();
    Thanks.

    Issue resolved.
    remove selectionListener and selectedRowKeys....
    code to get all the selectedRows.
    RowSetIterator rs = dcIterator.getRowSetIterator();
    RowKeySet rks = this.t1.getSelectedRowKeys();
    Iterator rksIter = rks.iterator();
    while (rksIter.hasNext()) {
    List l = (List) rksIter.next();
    Key key = (Key)l.get(0);
    Row row = rs.getRow(key);
    Thanks.

  • Creating View for a table with parent child relation in table

    I need help creating a view. It is on a base table which is a metadata table.It is usinf parent child relationship. There are four types of objects, Job, Workflow, Dataflow and ABAP dataflow. Job would be the root parent everytime. I have saved all the jobs
    of the project in another table TABLE_JOB with column name JOB_NAME. Query should iteratively start from the job and search all the child nodes and then display all child with the job name. Attached are the images of base table data and expected view data
    and also the excel sheet with data.Picture 1 is the sample data in base table. Picture 2 is data in the view.
    Base Table
    PARENT_OBJ
    PAREBT_OBJ_TYPE
    DESCEN_OBJ
    DESCEN_OBJ_TYPE
    JOB_A
    JOB
    WF_1
    WORKFLOW
    JOB_A
    JOB
    DF_1
    DATAFLOW
    WF_1
    WORKFLOW
    DF_2
    DATAFLOW
    DF_1
    DATAFLOW
    ADF_1
    ADF
    JOB_B
    JOB
    WF_2
    WORKFLOW
    JOB_B
    JOB
    WF_3
    WORKFLOW
    WF_2
    WORKFLOW
    DF_3
    DATAFLOW
    WF_3
    WORKFLOW
    DF_4
    DATAFLOW
    DF_4
    DATAFLOW
    ADF_2
    ADF
    View
    Job_Name
    Flow_Name
    Flow_Type
    Job_A
    WF_1
    WORKFLOW
    Job_A
    DF_1
    DATAFLOW
    Job_A
    DF_2
    DATAFLOW
    Job_A
    ADF_1
    ADF
    Job_B
    WF_2
    WORKFLOW
    Job_B
    WF_3
    WORKFLOW
    Job_B
    DF_3
    DATAFLOW
    Job_B
    DF_4
    DATAFLOW
    Job_B
    ADF_2
    ADF
    I implemented the same in oracle using CONNECT_BY_ROOT and START WITH.
    Regards,
    Megha

    I think what you need is recursive CTE
    Consider your table below
    create table basetable
    (PARENT_OBJ varchar(10),
    PAREBT_OBJ_TYPE varchar(10),
    DESCEN_OBJ varchar(10),DESCEN_OBJ_TYPE varchar(10))
    INSERT basetable(PARENT_OBJ,PAREBT_OBJ_TYPE,DESCEN_OBJ,DESCEN_OBJ_TYPE)
    VALUES('JOB_A','JOB','WF_1','WORKFLOW'),
    ('JOB_A','JOB','DF_1','DATAFLOW'),
    ('WF_1','WORKFLOW','DF_2','DATAFLOW'),
    ('DF_1','DATAFLOW','ADF_1','ADF'),
    ('JOB_B','JOB','WF_2','WORKFLOW'),
    ('JOB_B','JOB','WF_3','WORKFLOW'),
    ('WF_2','WORKFLOW','DF_3','DATAFLOW'),
    ('WF_3','WORKFLOW','DF_4','DATAFLOW'),
    ('DF_4','DATAFLOW','ADF_2','ADF')
    ie first create a UDF like below to get hierarchy recursively
    CREATE FUNCTION GetHierarchy
    @Object varchar(10)
    RETURNS @RESULTS table
    PARENT_OBJ varchar(10),
    DESCEN_OBJ varchar(10),
    DESCEN_OBJ_TYPE varchar(10)
    AS
    BEGIN
    ;With CTE
    AS
    SELECT PARENT_OBJ,DESCEN_OBJ,DESCEN_OBJ_TYPE
    FROM basetable
    WHERE PARENT_OBJ = @Object
    UNION ALL
    SELECT b.PARENT_OBJ,b.DESCEN_OBJ,b.DESCEN_OBJ_TYPE
    FROM CTE c
    JOIN basetable b
    ON b.PARENT_OBJ = c.DESCEN_OBJ
    INSERT @RESULTS
    SELECT @Object,DESCEN_OBJ,DESCEN_OBJ_TYPE
    FROM CTE
    OPTION (MAXRECURSION 0)
    RETURN
    END
    Then you can invoke it as below
    SELECT * FROM dbo.GetHierarchy('JOB_A')
    Now you need to use this for every parent obj (start obj) in view 
    for that create view as below
    CREATE VIEW vw_Table
    AS
    SELECT f.*
    FROM (SELECT DISTINCT PARENT_OBJ FROM basetable r
    WHERE NOT EXISTS (SELECT 1
    FROM basetable WHERE DESCEN_OBJ = r.PARENT_OBJ)
    )b
    CROSS APPLY dbo.GetHierarchy(b.PARENT_OBJ) f
    GO
    This will make sure it will give full hieraracy for each start object
    Now just call view as below and see the output
    SELECT * FROM vw_table
    Output
    PARENT_OBJ DESCEN_OBJ DESCEN_OBJ_TYPE
    JOB_A WF_1 WORKFLOW
    JOB_A DF_1 DATAFLOW
    JOB_A ADF_1 ADF
    JOB_A DF_2 DATAFLOW
    JOB_B WF_2 WORKFLOW
    JOB_B WF_3 WORKFLOW
    JOB_B DF_4 DATAFLOW
    JOB_B ADF_2 ADF
    JOB_B DF_3 DATAFLOW
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • MATERIALIZED view on two tables with Fast Refresh

    i Wanted to create MV on two tables with Fast refresh on commit.
    I followed below steps
    create materialized view log on t1 WITH PRIMARY KEY, rowid;
    create materialized view log on t2 WITH PRIMARY KEY, rowid;
    CREATE MATERIALIZED VIEW ETL_ENTITY_DIVISION_ASSO_MV
    REFRESH fast ON commit
    ENABLE QUERY REWRITE
    AS
    select A.ROWID B.ROWID,a.c1, DECODE(a.c1,'aaa','xxx','aaa') c2
    from t1 A
    join t2 b
    on AB.c1= CD.c2;
    i am getting below error.
    Error report:
    SQL Error: ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    12054. 00000 - "cannot set the ON COMMIT refresh attribute for the materialized view"
    *Cause:    The materialized view did not satisfy conditions for refresh at
    commit time.
    *Action:   Specify only valid options.
    Basically i want to take record in MV by joinig two tables and if both of the base tables will updated then record should reflect in materialised view.
    Please do the needfull.

    does the table support PCT? the other restrictions on joins look to be ok in your statement.
    maybe try creating first with on demand instead of commit to see does it create.
    http://docs.oracle.com/cd/B19306_01/server.102/b14223/basicmv.htm
    >
    Materialized Views Containing Only Joins
    Some materialized views contain only joins and no aggregates, such as in Example 8-4, where a materialized view is created that joins the sales table to the times and customers tables. The advantage of creating this type of materialized view is that expensive joins will be precalculated.
    Fast refresh for a materialized view containing only joins is possible after any type of DML to the base tables (direct-path or conventional INSERT, UPDATE, or DELETE).
    A materialized view containing only joins can be defined to be refreshed ON COMMIT or ON DEMAND. If it is ON COMMIT, the refresh is performed at commit time of the transaction that does DML on the materialized view's detail table.
    If you specify REFRESH FAST, Oracle performs further verification of the query definition to ensure that fast refresh can be performed if any of the detail tables change. These additional checks are:
    A materialized view log must be present for each detail table unless the table supports PCT. Also, when a materialized view log is required, the ROWID column must be present in each materialized view log.
    The rowids of all the detail tables must appear in the SELECT list of the materialized view query definition.
    If some of these restrictions are not met, you can create the materialized view as REFRESH FORCE to take advantage of fast refresh when it is possible. If one of the tables did not meet all of the criteria, but the other tables did, the materialized view would still be fast refreshable with respect to the other tables for which all the criteria are met.

  • Create a view from multiple tables

    Hi all,
    I am a newbie, so sorry if this is a "basic" question.
    I had 3 tables TAB1, TAB2 and TAB3
    TAB1 has
    STU_ID(pk), NAME, GRADE, ADDRESS
    TAB2 has
    COURSE_ID(pk), STU_ID(fk), COURSE_NAME, ROOM_NUM, TIME, DAY
    TAB3 has
    MENTOR_NAME, TITLE, AVAILABLE_DAYS
    Now I want to create a view(or query) that returns STU_ID, COURSE_NAME, NAME, GRADE, MENTOR_NAME and TITLE.
    When I tried writing a query like
    SELECT a.STU_ID, b.COURSE_NAME, a.NAME, a.GRADE, c.MENTOR_NAME, a.TITLE
    FROM TAB1 a, TAB2 b, TAB3 c
    WHERE a.STU_ID=b.STU_ID
    I am getting multiple results..like I'm getting Mentor name 4 times, name 4 times like that.
    So can anybody help me in writing the query for this....a "VIEW" would be appreciated.
    Thanks In Advance
    Srra

    You query should return all the columns in the select list once for each and every row that meets the specified join condition, how does this differ from what you are getting?
    So if tableA is the student table with only one row per student you would expect to see the student data duplicated once for every matching course row found in tableB, and so on when tableC is added in.
    If you need help please post partial results and then explain what results you want.
    HTH -- Mark D Powell --
    PS as sb mention you forgot your join condition to tableC which would multiply tableC by the other tables.
    Edited by: Mark D Powell on Feb 3, 2010 9:18 AM

  • Creat View from Multiple tables , Multiple Select

    Hello  Everyone ,
    I have a question and am not sure if this the correct forum to post it .
    I have two table studentTable and CourseTable which is each student  take more than one course . 1:M
    for example Student1 take 2 courses (C1 ,  C2).
    Student2 take 3 courses (C1,C2, C3).
    I need to create a table/View that contain student information plus all the courses and the score for each  course in one row.
    for example
    Row1= Student1_Id ,C1_code ,C1_name  ,C1_Score ,C2_code,C2_name ,C2_Score
    Row2=
    Student2_Id,C1_code,  C1_name,C1_Score,C2_code ,C2_name ,C2_Score ,  C3_code,C3_name,C3_Score
    and since Student 1 just took two courses  , I  should enter NULL in 'Course 3 fields'
    My Struggle is in the insert  statement
    I tried the following but it show an error
    Insert Into  Newtable
    ( St_ID, C1_code,c1_name, C1_Score ,C2_code  ,C2_name,C2_score,C3_code ,C3_name,C3_score)
    Select
    (Select St_ID from  StudentTable)
    (Select C_code,c_name,c_Score
    from  Coursetable,SudentTable
    where course.Stid =Studet.stid)
    (Select  C_code,c_name,c_Score
    from course ,student
    where course.Stid =Studet.stid  ),
    (Select C_code,c_name,c_Score
    from course ,student
    where  course.Stid =Studet.stid );
    I'm fully aware that the New table will break  the rules of normalization ,but I need it in this way for specifc purpose.
    I tried  also the PIVOT BY functionality but no luck with it .
    FYI , I'm not  expert in using SQL Syntax , I just know the basic.
    I will be great full for  any helpfull suggestions to try ,
    thank you very  much.

    First Table is Member table which Represent
    Students Information
    .The fields in this table are
    member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
    widening_participation_level, nationality
    Second Table is Modules table which include
    the Courses' scores that Student took .
    The fields in this table are
    Module_result_k(Primary Key), member_sk(Foreign key to connect to Member table), member_stage_sk
    ,module_k(Foreign key to connect to Module table), module_confirmed_grade_src, credit_or_result
    Third Table is
    AllModuleInfo which is include
    general information for each course .The fields in this table are
    Module_k (Primary key), module_name ,module_code, Module_credit, Module stage.
    The New table
    that I will create has the following fields
    member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
    widening_participation_level, nationality 
    " This will be retrieved from Member table"
    Also will include
    Module 1_name ,module1_code, Module1_credit, Module1_ stage, member1_stage_sk
    , module1_confirmed_grade_src, credit1_or_result
    Module 2_name ,module2_code, Module2_credit, Module2_ stage, member2_stage_sk
    , module2_confirmed_grade_src, credit2_or_result
    I will repeat this fields 14 times which is equal to Maximum courses number 
    that any of the students took.
    //// I hope now my questions become more clear

  • Authorization for all the maintenance views from one table

    I have one table with data related to 5 systems.
    I have created views with related data for each system.
    These all are from one table only. while i am editing in one view, i must be able to edit the another view also. at a time 2 users cant edit the same view but at a time two users have to edit two different viws from same table.
    I have to provide all authorization to all views at the same time.How to achieve this?.
    Thanks.
    Edited by: pagidala Ramesh on Oct 27, 2008 10:52 AM

    Hi Pagidala,
    This is my idea how much it can help you i am not sure but, create txcode for views and assign the authorizations for the txcodes according to your requirements. May be your issue will resolve.
    Cheers!!
    VEnk@

  • Value Set whose Data come from customize table with distinct record

    Dear All,
    I am new in Oracle EBS, currently i am creating value set whose data come from customize table which have 40 duplicate record in which distinct column return 27 record .
    Table XX_ROUND_SET
    Columns (Transactions_id,set_record)
    Total Record (40)
    Distinct Record (Set_Record --> 27)
    I just want to show only 27 record in it.
    Thanks
    Rehan

    Hi Rehan,
    PL.IGNORE MY EARLIER UPDATE AND TREAT THIS UPDATE AS YOUR SOLUTION.
    Method 1
    Create the VIEW based on DISTINCT values; use the VIEW for creates the VALUESET.
    Method 2
    Paste the QUERY in TABLE field with alias name, and give the column name (with alias name).
    (in your case )
    TABLE NAME : ( select distinct transactions_id, set_record from XX_ROUND_SET ) Y
    VALUE : Y.transactions_id
    HTH
    Sanjay

  • Want to Join two tables with cursors

    Can anyone tell me how to join two tables only by cursors.
    Not with:
    1.Joining condition
    2.Procedure etc.
    Only cursors with passing parameters.
    Sowmya

    This is my assignment. I want to get the matching records from both tables. I have pk, fk for both tables for deptno.Can I pass parameter for this.
    dept table:
    deptno deptname
    10 sales
    20 Erp
    30 hr
    40     marketing
    emp table:
    Empno deptno Name
    1 10 lee
    2 20 hans
    3 10 peter
    4 30 james
    5 30 king
    Output should be:
    deptno empname empno deptname
    10 lee 1 sales
    10 peter 3 erp
    30 james 4 hr
    30 king 5 marketing

Maybe you are looking for

  • Xmonad.hs file: I need a template, but the official one gives errors

    I just installed Xmonad and I am LOVING it, but I need some help setting up an xmonad.hs file. I created one in ~/.xmonad/xmonad.hs and looked for a well-commented template since I don't know any Haskell (or any programming language, for that matter)

  • My iPhone 4 doesn't like to SYNC music to my Ford

    I have a Ford Edge with the SYNC system. My old iPhone 3G worked great with it. My new iPhone 4 works fine for phone calls but won't play music from the phone even when hooked up with the USB cable. When I'm doing it by Bluetooth, I can barely here s

  • User ID & log in fix... to preserve or not preserve during the fix?

    OK I have the same problem as most everyone else here but am not sure which preference to choose during the archive and install fix suggested by most everyone. So which option should I choose before I embark on this crazy bug fixing adventure. Detail

  • I am having a problem installing Photoshop Elements 11.

    The installation begins, however a message appears stating that an error was encountered while installing Shared Technoligies. The message tells me to restart my system. The error message still occures. How can I resolve the problem?

  • HT2500 deleting email

    I have thousands of emails in different files in Mail even after I delete them. How do I permanently ?