How to create a view consisting of data from tables in2 different databases

Using Oracle 10.2g
I have 2 databases Gus and haggis on Comqdhb schema.
glink indicates a databse link between Haggis and Gus
In Gus there are tables student,subject,grade,school containing columns like upn...
STUDENT
upn
academicYear
SUBJECT
subject
GRADE
examlevel
grade
SCHOOL
sn
In HAGGIS there are tables student,grade,teacher containing columns upn...desc below.
STUDENT
upn
GRADE
grade
upn
academicyear
level
Create view in your HAGGIS database which will join all of the exam grades together. You should have one view which will produce the following relation :
examGrade(upn, subject, examlevel, sn, grade,academicYear)
so I need to create a view which gets the data from both the tables in both the databases.
create view as examGrade(upn, subject, examlevel, sn, grade,academicYear) as select s.upn
But i am not getting how to select a column from 2 tables in different databases
I mean if i said
select upn from comqdhb.student@glink,comqdhb.student;
select upn from comqdhb.student@glink,comqdhb.student
ERROR at line 1:
ORA-00918: column ambiguously defined
help me out,Thank you.

Thank you for the reply will follow up the code format
Create views in your HAGGIS schema database which will join all of the exam grades together. You should have one view which will produce the following relation :
examGrade(upn, subject, examlevel, sn, grade,academicYear)
I understand that there wont be duplication when we use conditions
If i query
select count(upn)
from   comqdhb.student@glink I get 9000
but after the union
create view examGrade(upn, subject, examlevel, sn, grade,academicYear)
as
select distinct s.upn as upn
,                  g.subject as subject
,                  g."LEVEL" as examlevel
,                  g.grade as grades
,                  '9364097'
,                  to_number(g.academicyear) as academicyear
from             comqdhb.student s
,                   comqdhb.grade g
where           s.upn=g.upn
union
select            s.upn
,                   sb.subject
,                   g.elevel
,                   g.grade
,                   s.acyr
,                   sc.sn
from              comqdhb.subject@glink sb
,                   comqdhb.student@glink s
,                    comqdhb.gradevalues@glink g
,                    comqdhb.school@glink sc,
,                    comqdhb.studentingroup@glink sg
,                    comqdhb.teachinggroup@glink tg
where            sb.sid=tg.sid
and                tg.gid=sg.gid
and                sg.upn=s.upn
and                g."LEVEL"=tg.elevel
and                s.school=sc.id
and                sc.id=tg.id; returns
count(upn) from exam gradeIt gets stuck actually sometimes it returns
932002 some results.
2:
Another problem i am having which i am trying to solve and written up my ideas but haven't been getting the expected results.Hope you can help.Thank you.
Information:
=======
All children take exams at the age of 16 called a General Certificate of SecondaryEducation (GCSE).
They have to study and take exams in Mathematics, English and Science, and can take other subjects such as History, French, Art etc. Most students will study between 5 and 10 different subjects before taking their GCSEs.
For each exam, a student is awarded a grade from A*, A, B,C,D,E,F,G,U,X An A* grade is the best grade achievable and an X is the worst grade.
In order to analyze how students have performed, each grade is mapped to a numeric value as follows:
Grade Numerical score
A* 8
A 7
B 6
C 5
D 4
E 3
F 2
G 1
U 0
X 0
Now why i need this avgGCSE is because i have to create a view containing avgGCSE of the students it is used in the next question where a condition is avgGCSE is between 6.5 and 7
In order to calculate the avgGCSE the idea is to calculate the grades of the students and map the grades to their corresponding scores/values
add them all up and div by the total no of grades to get the avg.
desc comqdhb.STUDENT@glink;
STUDENT
=======
UPN
FNAME
CNAME
DOB
GENDER
PREVIOUSSCHOOL
XGCSE
SCHOOL
ACYR
STUDENTINGROUP
=============
UPN
GID
STARTDATE
ENDDATE
GRADE
GRADEVALUES
===========
GRADE
LEVEL
VALUE
I have a opinion that xgcse in STUDENT table refers to the avgGCSE which i want to calculate as when i asked my professor as to what xgcse he said that he forgot to take it out of the table and it is not necessary while creating avggcse.
select *
from comqdhb.student@glink
where xgcse<6.5; Displaying a result
returns:
UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
===========================================================================
1011 KIMBERLY ABBOT 07-JUL-79 f none 3.93500948 2 2
select *
from comqdhb.student@glink
where xgcse between 6.5 and 7 and upn = 1386; Displaying a result
returns:
UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
===========================================================================
1386 STEPHANIE AANNESSON 15-JAN-79 f none 6.88873 2 2 so if xgcse is the avgGCSE then upn 1011 has avggcse<6.5 and 1386 has avggcse >6.5
my idea was backward strategy like so now if we find out upn 1368 has suppose xgcse(avggcse)>6.5 how to extract the avggcse for the particular upn We need to map grades from GRADEVALUES to grade in STUDENTINGROUP and map upn from studentingroup to upn in student to output the values for the corresponding grades from GRADEVALUES
select grade
from comqdhb.studentingroup@glink
where upn = 1011;
Result:
GRADE
=====
D
F
B
E
C
E
E
B
8 rows selected. Mapping each grade to the corresponding value and calculating we get
32/8=4 total(values to corresponding grades)/no of grades.
But the xgcse for upn 1011 is 3.935 and i am getting 4!! maybe xgcse isn't avggrade but ? is the procedure by me correct for calculating avggcse
select grade
from comqdhb.studentingroup@glink
where upn = 1386;
Result:
GRADE
======
A*
A*
A*
A*
B
A*
A*
A
B
B
B
11 rows selected. grade to the corresponding value and calculating we get
79/11=7.12 total(values to corresponding grades)/no of grades.
But the xgcse for upn 1011 is 6.88... and i am getting 7.12!!
But another problem
when i say
select   g.value,g.grade
from     comqdhb.gradevalues@glink g
,        comqdhb.studentingroup@glink sg
where    g.grade=sg.grade
and      sg.upn=1011;
result:
======
VALUE GRADE
===========
  100 B
  100 B
   80 C
   60 D
   40 E
   40 E
   40 E
   20 F
    6 B
    6 B
    5 C
VALUE GRADE
=============
    4 D
    3 E
    3 E
    3 E
    2 F
16 rows selected.
select   distinct g.value,g.grade
from     comqdhb.gradevalues@glink g
,        comqdhb.studentingroup@glink sg
where    g.grade=sg.grade
and      sg.upn=1011;
result:
======
VALUE GRADE
============
     2 F
   100 B
     6 B
     3 E
    60 D
     5 C
     4 D
    80 C
    40 E
    20 F
10 rows selected. I am getting only 8 for the query
select grade
from comqdhb.studentingroup@glink
where upn = 1386; here its becomming 10 and also its displaying values as 100 and ...
select distinct *
from   comqdhb.gradevalues@glink;
GRADEVALUES
===========
LEVEL      GRADE           VALUE
================================
a          A                 120
a          B                 100
a          C                  80
a          D                  60
a          E                  40
a          F                  20
a          U                   0
a          X                   0
g          A                   7
g          A*                  8
g          B                   6
LEVEL      GRADE           VALUE
================================
g          C                   5
g          D                   4
g          E                   3
g          F                   2
g          G                   1
g          U                   0
g          X                   0
18 rows selected. I was hoping if i could map the grades and get the values and calculate avggrade by total(values)/count(values)that would be it but here there are values like 100...
select  sum(g.value)/count(g.grade) as avggrade
from    comqdhb.gradevalues@glink g
,         comqdhb.studentingroup@glink sg
where  g.grade=sg.grade
and     sg.upn=1386;
avggrade
========
37.4375 the avggrade cant be this big and when i map each grade i obtained for 1368 like a to 7+b to 6 so on i get avggrade 7.12
kindly help.
Edited by: Trooper on Dec 15, 2008 4:49 AM

Similar Messages

  • Create a trigger to copy data from table A to table B

    Hi,
    I been trying with no success to create a trigger on table a , so when the user update or delete or insert data on that table, I would like to copy all data from table a to table b BEFORE, the statement execute, I am using Oracle database 10g XE. It's URGENT and I would appreciate any quick response.
    Thank you in advance.

    > All what I needed to do is to copy / beckup the tableA before any changes done to the table
    Why? You are not giving us a problem to look at, analyse, and assist with - you are giving us a solution. That solution says "backup table before changes are made".
    This solution sounds very strange in the context of a RDBMS. Even stranger when dealing with relational design as one would use date and time to keep track of how data is changing.
    This, and your implementation of the solution (using triggers and DDL inside it!), makes me question whether this solution is indeed at all a solution. I see flaws and problems all the way.
    What happens if two users inserts at the same time into table A? Two truncates will be fired on table B. Then the entire contents of A (and not the changes) inserted into table B? Ridiculous...
    Thus from my point of view, looking at what you have presented to the forum in this thread, you do not seem to have any grasp on how to correctly use a RDBMS, never mind use Oracle.
    Ignorance is not a problem. It is fairly easily curable. Which is why I referred you to the manuals.
    Alternatively, instead of asking the forum how to make a flawed solution works, how about instead telling us the actual problem you are trying to solve?

  • How to create web part and retrieve data from a scheduled task?

    Hi,
    I am new to SP, so I think you can guide me. I have  a scheduled task which gets currency data. I wonder if there is  way to show them on a web part. There will be currnecy names, buy and sell data on this web part. I would be glad if you can show
    me step by step how to create this web part on SP.
    Thanks in advance.
    Best Regards.

    Hi,
    thanks for the reply so I advice on that case to write code in the task schedule to write the data into a SharePoint list, if the scheduled task is on the same server as SharePoint then use Object model if it on another server then use client object model
    to write data to a list
    then on SharePoint site you will just add out of the box web part to display the list where you stored the data
    to save data using Object model:
    http://msdn.microsoft.com/en-us/library/office/ms467435(v=office.14).aspx
    http://www.go4sharepoint.com/Code/insert-list-item-sharepoint-object-286.aspx
    to save data using client object model
    http://www.codeproject.com/Articles/268196/SharePoint-Client-Object-Model
    Kind Regards,
    John Naguib
    Technical Consultant/Architect
    MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation
    Please remember to mark your question as answered if this solves your problem

  • Create a view to shows data from multiple rows in a single column

    Hi all - this is probably posted in the wrong forum but I couldn't find which was the correct one.
    I am almost a complete novice at sql but I have a need to create a view which can be developed at 10g (which runs efficiently as the volumes are likely to be high) which will do the following.
    Original table with columns Parent_code, Child_code
    Parent_Code Child_Code
    1000 2000
    1000 3000
    1000 4000
    2000 3000
    2000 5000
    (note Parents can have multiple children and a child can have multiple parents!)
    What I need to end up with in my view is the following
    Child_Code Parent_List
    2000 '1000 (3)'
    3000 '1000 (3), 2000 (2)'
    4000 '1000 (3)'
    5000 '2000 (2)'
    Note the number in parantheses is the number of children that the parent has - ie in the original table parent 1000 has 3 rows (one for each child)
    This view is then to be used as a look up (on child code) for a business objects report.
    Is there anyone who could PLEASE, PLEASE help me fairly quickly on this as I have very little time to find a solution?

    Hi,
    You can test these ones :
    select child_code
         , ltrim(sys_connect_by_path(parent_info,', '), ', ') as parent_list
    from (
      select child_code
           , to_char(parent_code) ||
             ' (' ||
             count(*) over(partition by parent_code) ||
             ')' as parent_info
           , row_number() over(partition by child_code order by parent_code) rn
      from your_table
    where connect_by_isleaf = 1
    connect by prior rn = rn-1
           and prior child_code = child_code
    start with rn = 1
    select child_code,
           rtrim(
             extract(
               xmlagg(xmlelement("e",parent_info||', ') order by parent_info)
             , '//text()'
           ) as parent_list
    from (
      select child_code,
             to_char(parent_code) ||
             ' (' ||
             count(*) over(partition by parent_code) ||
             ')' as parent_info
      from your_table
    group by child_code
    ;What you need is called "string aggregation".
    See here for various techniques, including the two above : http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

  • How to create a view on a Non-Transparent Tables.

    Hi,
    i want to create a view on P0001 & P0002 tables.
    these two tables are non transparent.
    Can any body help me ,
    Thanks in Advance,
    Regards
    Vinay

    Hi Vinay
    It seems you program HR-ABAP. Generally it is not required to create views since we use LDB (Logical database) utilizations in our programs. Doesn't it satisfy your requirement? Or is it required at somewhere you do not use LDB?
    *--Serdar

  • Please let me know how to write the Query to fetch data from tables

    Hi Folks,
    Please let me know how to get the data from  different tables using the functionality SQ03,SQ02  and SQ01 .
    Helpful answers will points awarded.
    Regards,
    Ram.

    Dear Ram,
    Please find the below link which gives in detail with screen shots.
    [SAP Query|http://media.techtarget.com/searchSAP/downloads/Teach_yourself_SAP_C20.pdf#search=%22CREATE%20REPORT%20USING%20SQVI%20%2C%20SAP%22]
    Thanks
    Murtuza

  • How do i select last 5 minutes data from table

    there is table called 'x' which has cron job set of interval=5 min,i want to select last 5 min data and delete rest of the data in it or save in one of the table say 'y'.how do i going to do it???kindly help out please??
    Edited by: user10341747 on Sep 24, 2008 10:20 AM

    this is just explanation of other members reply
    insert into Y
    select * from X where timestamp_variable between systimestamp - 5/(24*60) and systimestamp
    this select gives last 5 min data out of that table x .
    members can correct me if iam wrong.
    Thank you.

  • How to create a view on tables with different keys?

    I have to create a View on:
    Z3PVR: Transparent Table
    BSEG: Cluster Table
    CKIS: Transparent Table
    BKPF: Transparent Table
    RV61A: Structure
    T001: Transparent Table
    All the tables have different "Key Fields" and the structure has no "Key Fields". When i create the view, what do I mention in the "JOIN FIELDS" tab. and how do i create the view with the structure?
    Please advise.

    How to create a view on a Non-Transparent Tables.
    how to create view?
    HELP.. How to create a view with the tables with ALV

  • How to create a view with Oracle apps Org initialization ?

    Hi,
    How to create a view which needs Oracle apps org initialization to provide the correct data .
    The purpose of the view is to be accessed in Primavera DB via a DB link for reporting purpose.
    So how should the org be initialized so that the view returns the correct data when accessed from the remote data base using the DB link?
    EX: step1 run fnd_client_info.set_org_context for the org
    step2 query the veiw returns correct data in Oracle.
    How can this be achieved if the view needs to be accessed via DB link?
    sample view sql :
    select po_header_id
    from po_distributions_all pod
    where (apps.po_intg_document_funds_grp.get_active_encumbrance_func
    ('PO',
    pod.po_distribution_id
    ) <> 0
    Thanks in advance!
    Darshini

    Hi,
    This is not possible in Oracle. What u can do is create the view without the where clasue and supply the where clause at runtime.
    Hope this helps...
    Regards,
    Ganesh R

  • How to create a line type in data dictionary

    How to create a line type in data dictionary?Please explain step by step?
    Thanks & Regads,
    Sairam

    Hi,
    the details abbout the line type.
    The line type of a table type can be defined by:
    o Specification of a type that already exists (data element,
    structure, table type, table, view) whose properties are then copie
    as properties of the defined table line.
    o Direct type input, where data type, number of positions, and, if
    required, decimal places, are entered directly.
    o Specification of a reference type.
    and SE11 and click on datatype and click on table type and enter the line type.
    Thanks
    Shiva

  • How to restrict data from tables in a view cluster

    Hi,
    I have 5 Z* tables, Company code is the common code in all of these.
    I have created a view cluster on these five tables.
    My requirement is to viewcluster should display the data of the user's company code.
    When i see the data in SE54 it is showing the proper data(i.e data which is related to users company code) for some of the tables.
    And displaying all company codes data for some of the tables.
    What can be the issue here ?
    Do we need to map the data from proper data displaying tables to these tables ? if so How to do that ?
    Please help on how i can solve this issue.
    Regards,
    Sunil Tata.

    Here is a small utility that can be used to copy and paste between a table and Excel.
    I have been obliged to slice the llb into small chuncks for internet technical issues. Sorry...
    CCMessage Edited by chilly charly on 04-02-2005 03:21 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Copy.zip ‏24 KB
    Paste.zip ‏22 KB
    CopyPaste example.zip ‏11 KB

  • How to create dynamic view in hr report category

    i want to make company code mandetory in in selection screen given by logical data base PNP here i want to make field mandetory. so how to create dynamic view in hr report category.
    thanks in advance

    solved by self

  • How to create new view without interlinking with gantt chart or resource views

    ok clear
    one another question
       In msp how to create new view without interlinking with gantt chart or resource views

    Hi Shiv PMC--
    I splitted your question above in another thread in order not to have  a huge thread with many topics in it.
    That being said, I'm not sure to understand. A view is just a manner to display MS Project data with columns. A view can have a table with column (left part) associated with a Gantt chart. It can also just contain a table with no Gantt chart (like the task
    table) or a table with a timephased grid (resource and task usage).
    Please give us more information, maybe with a concrete example so we can help you.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • How to  create i view  in visual composer give details screenshots

    how to  create i view  in visual composer give details screenshots

    Hi,
    Go through these threads
    VisualComposer
    http://help.sap.com/bp_epv170/EP_US/HTML/Executive_Cockpit.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1752b737-0401-0010-0ba3-87c3eda8c6ce
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e019d290-0201-0010-f186-8630a949800a
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30987099-a74c-2a10-70b5-a2751ce79359
    http://help.sap.com/saphelp_nw04/helpdata/en/fd/4a7e40417c6d1de10000000a1550b0/content.htm
    Tarak
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00b9ba6d-1291-2a10-208d-bd27544e7939

  • How to create a view?

    HI friends,
                  Can any one help me out in creation of view i am suceeded in creation but while display it is showing no records
    i think i am going wrong in selection conditions....can anyone give me clear steps to create a  view.?

    Hi,
    The followings are different types of views:
    - Database View (SE11)
    Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.
    In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.
    - Help View ( SE54)
    Help views are used to output additional information when the online help system is called.
    When the F4 button is pressed for a screen field, a check is first made on whether a matchcode is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view.
    Go thru this link plzz
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ecf9446011d189700000e8322d00/frameset.htm
    Difference between "Help View" and "Search Help"
    - Projection View
    Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.
    A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.
    - Maintenance View ( SE54 )
    Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
    Please have a look at below link. It will help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed06446011d189700000e8322d00/frameset.htm
    for more detailed info look on:
    http://www.sap-img.com/abap/what-is-the-different-types-and-usage-of-views.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abap+dictionary&
    1.Go to se11
    2. select view radiobutton and give a name
    3. Create
    4. select type of view you want to create. Such as database view.
    5. give short description
    6. give a table name such as mara
    7. press the pushbutton relationship. here you will find all the tables which are allowed to create view with mara.
    8. select one or mane tables.
    8 copy
    9.save , check and activate.
    cheers,
    vasavi
    kindly reward if helpful

Maybe you are looking for

  • Help with if/else in displaying data - (possibly foreach)

    Hello all, I've been trying to set something up, and I'm having difficulty getting it to work. Lines 84-111 have become my biggest difficulty.  I've got an if/else statement set up so that if one record has an image located on the localhost that imag

  • HT4686 How can I publish my website developed using iWeb and have all functions of the blog page work as it did with MobileMe?

    I have developed a website using iWeb and it includes a blog page selected from stock pages in iWeb.  I'm publishing it with GoDaddy and when I do that the interactive functions of the blog page don't work. (Adding comments and photos as well as sear

  • Screen dimming

    hey, i'm going to hook my macbook to my HDTV via the DVI adapter and then HDMI to the TV. My question is this: My Macbook has a screen dimming function, whether it's plugged into a wall socket or not after a short time of no operation the screen goes

  • Java WebDynpro - Sneak Preview

    Guyz, I installed java stack (sneak preview) couple of months back and when now i'm switching it on, my J2EE Server is automatically switching off after certain time..... upon checking logs in 'Developer Trace', it says its shutting down while licens

  • Quad + 7800 GT + two 20" cinema = issues

    So I'm running a quad with the GeForce 7800 GT and two new apple 20 inch displays. Occasionally, one monitor will go to sleep while I am working, and then the other will go to sleep, and then they will both wake up. Typically, it happens in bursts of