Is it OK to join to a view twice in the same select?

For instance
In this case RPT_PRIMARY_PATRON_DETAIL is a view.
SELECT
PATRON_ORDER.FINANCIAL_PATRON_ACCOUNT_ID,
FIN_PATRON_DETAIL.PATRON_ACCOUNT_NAME,
PATRON_ORDER.ATTENDING_PATRON_ACCOUNT_ID,
SO_PATRON_DETAIL.PATRON_ACCOUNT_NAME
FROM
RPT_COMMON_ORDER_LINE_ITEM
INNER JOIN PATRON_ORDER ON
PATRON_ORDER.ORDER_ID = RPT_COMMON_ORDER_LINE_ITEM.ORDER_ID
LEFT OUTER JOIN RPT_PRIMARY_PATRON_DETAIL FIN_PATRON_DETAIL ON
FIN_PATRON_DETAIL.PATRON_ACCOUNT_ID = PATRON_ORDER.FINANCIAL_PATRON_ACCOUNT_ID
LEFT OUTER JOIN RPT_PRIMARY_PATRON_DETAIL SO_PATRON_DETAIL ON
SO_PATRON_DETAIL.PATRON_ACCOUNT_ID = PATRON_ORDER.ATTENDING_PATRON_ACCOUNT_ID
WHERE
RPT_COMMON_ORDER_LINE_ITEM.REPORT_PROCESS_ID = P_REPORT_PROCESS_ID

riedelme wrote:
As BluShadow and Mohommed stated there should be no problem with functionality if you do it correctly. But joining views does not usually work too well performance-wise as the temp tables resulting from view use don't have indexes for effecient nested loops joins. Performance on view joins can be bad, as can using views of views.Are you sure? Views can use the indexes of the base tables they are based on as a view is just a SQL query definition that is embedded into the overall select statement at execution time...
Noddy example, but the first query using view and the second using direct base table access...
SQL> ed
Wrote file afiedt.buf
  1  select myemps.empno, myemps.ename, myemps2.deptno, myemps3.empno
  2  from myemps, myemps myemps2, myemps myemps3
  3  where myemps.empno = myemps2.empno
  4* and   myemps.empno = myemps3.empno
SQL> /
     EMPNO ENAME          DEPTNO      EMPNO
      7782 CLARK              10       7782
      7839 KING               10       7839
      7934 MILLER             10       7934
Execution Plan
Plan hash value: 1213642587
| Id  | Operation                     | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT              |              |     3 |    84 |     3   (0)| 00:00:01 |
|   1 |  NESTED LOOPS                 |              |     3 |    84 |     3   (0)| 00:00:01 |
|   2 |   NESTED LOOPS                |              |     3 |    63 |     3   (0)| 00:00:01 |
|   3 |    TABLE ACCESS BY INDEX ROWID| EMP          |     3 |    42 |     2   (0)| 00:00:01 |
|*  4 |     INDEX RANGE SCAN          | DEPT_IDX     |     3 |       |     1   (0)| 00:00:01 |
|*  5 |    TABLE ACCESS BY INDEX ROWID| EMP          |     1 |     7 |     1   (0)| 00:00:01 |
|*  6 |     INDEX UNIQUE SCAN         | SYS_C0054243 |     1 |       |     0   (0)| 00:00:01 |
|*  7 |   TABLE ACCESS BY INDEX ROWID | EMP          |     1 |     7 |     0   (0)| 00:00:01 |
|*  8 |    INDEX UNIQUE SCAN          | SYS_C0054243 |     1 |       |     0   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   4 - access("DEPTNO"=10)
   5 - filter("DEPTNO"=10)
   6 - access("EMPNO"="EMPNO")
   7 - filter("DEPTNO"=10)
   8 - access("EMPNO"="EMPNO")
SQL> ed
Wrote file afiedt.buf
  1  select myemps.empno, myemps.ename, myemps2.deptno, myemps3.empno
  2  from emp myemps, emp myemps2, emp myemps3
  3  where myemps.empno = myemps2.empno
  4  and   myemps.empno = myemps3.empno
  5  and   myemps.deptno = 10
  6  and   myemps2.deptno = 10
  7* and   myemps3.deptno = 10
SQL> /
     EMPNO ENAME          DEPTNO      EMPNO
      7782 CLARK              10       7782
      7839 KING               10       7839
      7934 MILLER             10       7934
Execution Plan
Plan hash value: 1213642587
| Id  | Operation                     | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT              |              |     3 |    84 |     3   (0)| 00:00:01 |
|   1 |  NESTED LOOPS                 |              |     3 |    84 |     3   (0)| 00:00:01 |
|   2 |   NESTED LOOPS                |              |     3 |    63 |     3   (0)| 00:00:01 |
|   3 |    TABLE ACCESS BY INDEX ROWID| EMP          |     3 |    42 |     2   (0)| 00:00:01 |
|*  4 |     INDEX RANGE SCAN          | DEPT_IDX     |     3 |       |     1   (0)| 00:00:01 |
|*  5 |    TABLE ACCESS BY INDEX ROWID| EMP          |     1 |     7 |     1   (0)| 00:00:01 |
|*  6 |     INDEX UNIQUE SCAN         | SYS_C0054243 |     1 |       |     0   (0)| 00:00:01 |
|*  7 |   TABLE ACCESS BY INDEX ROWID | EMP          |     1 |     7 |     0   (0)| 00:00:01 |
|*  8 |    INDEX UNIQUE SCAN          | SYS_C0054243 |     1 |       |     0   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   4 - access("MYEMPS"."DEPTNO"=10)
   5 - filter("MYEMPS2"."DEPTNO"=10)
   6 - access("MYEMPS"."EMPNO"="MYEMPS2"."EMPNO")
   7 - filter("MYEMPS3"."DEPTNO"=10)
   8 - access("MYEMPS"."EMPNO"="MYEMPS3"."EMPNO")
SQL>No difference.

Similar Messages

  • View objects referencing the same entity

    The behaviour occurs in every version of jdeveloper ADF BC i have tried so far (10g, 11g).
    I have 2 updatable view objects referencing the same entity object. When i create a new record using the first view object and before commiting the data to the database i navigate to the second
    view object. Suprisingly the second view object is populated with the same data that is posted on the first view object. It seems like both view objects are referencing the same entity object instance.
    Is any way to overcome this strange behaviour.
    Thanks

    As Timo says think of the EO as a record cache. If you had 700 VOs all based on the same EO, it would be ideal to store the same record(s) 700 times in the midtier as it would consume vasts amount of memory. Thus the EO cache.
    If you do want to separate the VOs, you've 3 options:
    1) Use separate EOs for each VO (not ideal)
    2) Expose each VO under their own root level Application Module - a separate EO cache instance for each VO will be created at runtime - however you need to be careful between the VO/EO pairs, you don't update the same record, as you'll get record locks/contention
    3) If you're using task flows in 11g, use the Always Begin New Transaction option for each screen/fragment for each VO. This is the equivalent of 2 but from the task flow level - however again you need to be careful on record locks.
    CM.

  • TS1398 I have an iphone 3gs and since I made the 6.01 update everytime I want to join a wireless network I get the same error "incorrect password" when I now it's correct, any one have a solution for this? Tks

    I have an iPhone 3gs and since I made the 6.01 update everytime I want to join a wireless network I get the same error "incorrect password" when I now it's correct, any one have a solution for this? Tks

    I would say that you would want to look into the "Exchange Mode" for GMail.  That would allow your iPhone to sync calendars, contacts and email with GMail just fine.  Doing the same with your outlook should also then sync those same with your PC using Outlook.  I've done teh iPhone side of this, but I since I don't run Lookout for my email client, I'm not sure how that will work on the PC side.

  • MVC - More then one view managed by the same contrler.

    Ok, I have been reading and searching examples on the MVC .. but all the examples show just what to do when you have just one view of the model. What I f I have the more the n one view to handle the same model.
    As we know the views would need to be registerd inside the controler? How can I do this If I have more then one view?
    does anyone have any ideas!?
    Would it still be correct if when an action occures on my view instead of the controler capturing that event an handiling, I make my view call the controler to handle it?

    So in your opinion is it ok if I call my controler from the action event of my button?
    I just did a small example below:
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    public class Starter extends JFrame{
         private Model myModel = new Model();
         private Controler myControler = new Controler(myModel);
         public Starter(){
              JButton myButton = new JButton("Test");
              myButton.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        myControler.makeAction("Hello");
              this.getContentPane().add(myButton);
              this.pack();
              this.show();
         public static void main(String[] args){
              new Starter();
    }As you can see I am calling the controler to manage the new data from the action event of 'myButton' !
    Is the above code ok with the spirit of the MVC?

  • Problem with "Group By" in Views - Not Displaying the Same for All Users

    We have an Announcements List with its only View being set up to group by a metadata category field. We've done this many times on other kinds of lists and never had a problem. But with this list, about half the users can see only the ungrouped
    set of announcements, whereas others actually see the items within their groups.
    Those with "View" rights only can't see the grouped items - but that appears to be a coincidence as I promoted them to the same rights as others who can see them correctly, and that did NOT solve the problem. Everyone is using the exact same browser.
    Note: the users who do NOT see the groupings see only a single category entry that displays only the name of the category list (but not the names of the actual categories within the category list). All the announcements are grouped under that one
    entry for those users. This display looks exactly like it would if the categories had been left blank when the original announcements were created. But the categories are NOT blank, and the rest of the users can see them just fine, and the announcements display
    within their appropriate groups.
    I can't find anything in the View, the List Settings, or the User Permissions to explain this. What could be causing it, and how can I fix it?

    Browser settings are controlled by central IT and are all identical. 
    The only difference I can detect is the second set of users (that don't see the category options) have only Read rights, whereas those with Contribute (or above) rights can see the categories. It doesn't make
    sense that permissions would affect this, but I can't come up with any other differences.
    Microsoft will not allow me to upload images. it says I can't upload images until they have verified my account, but there is no clue as to how, if or when that might happen. If you can tell me how to fix that, I can provide samples.

  • Macpro and using a TV as another viewing option at the same time as display

    Hi,
    I have a MacPro and I'm trying to edit some footage but want to use my Radeon X1900 with one output going to my 23inch Apple display the other output going to my TV.
    I have the setting in FCP veiw menu to "All Frames" & "Digital Cinema Desktop Preview (not Main)"
    but either the playback is not on the TV or it only shows 1 frame at a time as if it is freezing when playing the sequence back, it freezes on both TV and display.
    I want whatever I'm viewing in either the canvas or timeline to be displayed on the TV also, is this possible?
    Getting rather frustrated!!!
    Help please?
    C.

    OK, I just searched this forum and found this post:
    http://discussions.apple.com/thread.jspa?threadID=1184628&tstart=100
    Here Shane describes the setting in some AV options about "mirror desktop" I looked for this setting and found it was unchecked.
    After checking it and trying again.... everything is perfect!!
    just incase anyone else needs to same info.
    C

  • How can I bind two text view elements in the same line?

    Hi all:
    In my case, it is not allowed that one text view is in the first line and another in the second line. How can I put them always in the same line?
    Thanks.

    Hi,
       as the window resizes the UIcontrols are also resized if wrapping is enabled and they will be in same row.
    as u mentioned they are two containers in root container but appears one by one do as below
    for root container
    set layout -  grid layout
    colcount - 2
    for 1st child container
    set layout -grid layout
    set colspan - 1
    as u requre 3 Ui control in it
    set colcount of child container to 3
    add the UI controls
    set the colspan of UI controls to 1.
    do as same for second container
    Thanks,
    yashpal

  • Preview and Generate view not displaying the same as design view

    RoboHelp HTML Ver 8.0.2.208.
    Hi all,
    I have a topic that will not generate or preview what is displayed in the design view.
    The topic is a table that uses a different image as the background for each cell (from the CSS).
    The background images display fine in design view but will not display when previewed or generated. Everything else is displayed but not the backgrounds.
    Any ideas.
    Thanks
    Wowronin

    You have this -
    </head>
    <script>
    <!--
    function msgopen(url, name, w, h)
    w += 32;
    h += 96;
    var win = window.open(url,
      name,
      'width=' + w + ', height=' + h + ', ' +
      'location=no, menubar=no, ' +
      'status=no, toolbar=no, scrollbars=yes, resizable=yes,screenX=2,screenY=2,left=100,top=100,');
    win.resizeTo(w, h);
    win.focus();
    // -->
    </script>
    <style type="text/css">
    #preloader  {
         position: absolute;
         top: 0;
         left: 0;
         right: 0;
         bottom: 0;
         background-color: #fefefe;
         z-index: 99;
        height: 100%;
    #status  {
         width: 200px;
         height: 200px;
         position: absolute;
         left: 50%;
         top: 50%;
         background-image: url(ajax-loader.gif);
         background-repeat: no-repeat;
         background-position: center;
         margin: -100px 0 0 -100px;
    </style>
    <body>
    In other words, you have a script block AND a CSS block between </head> and <body>. That's invalid code. Move it to where it belongs inside the <head> region.  You could have found this in an instant by checking the page here - http://validator.w3.org.

  • How to join each row with other in the same table without repeating, please help

    Hi,
    I have a table say Adjustment having following data
    Emp_Id                  
    Adjustment_id                      
    Date
    1000101               
    1000300                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                               
    2014-02-12 00:00:00.000
    1000101               
    1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                               
    2014-02-12 00:00:00.000
    1000102               
    1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000304                               
    2014-02-12 00:00:00.000
    And I want following records:
    Emp_Id                  
    Adjustment_id      Adjustment_id1              
          Date
    1000101               
    1000300                1000301                               
    2014-02-12 00:00:00.000
    1000101               
    1000300                1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000300               
    1000303                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                1000303                               
    2014-02-12 00:00:00.000
    1000101               
    1000302                1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                1000304                               
    2014-02-12 00:00:00.000
    1000102                    
    1000303               
         1000304                                       
    2014-02-12 00:00:00.000

    Hi Uri,
    I am using SQL Server 2008, and I am trying join each adjustment_id with all other adjustment_id having same Date and Emp_id.
    so for following table records:
    Emp_Id                 
    Adjustment_id                
    Date
    1000102               
    1000302                         
    2014-02-12 00:00:00
    1000102               
    1000303                         
    2014-02-12 00:00:00
     1000102                   
    1000304                               
    2014-02-12 00:00:00
    Output should be:
    Emp_Id        
    Adjustment_id      Adjustment_id     
    Date
    1000102      
    1000302               1000303              
    2014-02-12 00:00:00 (first row with 2nd)
    1000102      
    1000302               1000304              
    2014-02-12 00:00:00 (first row with 3rd)
    1000102      
    1000303               1000304              
    2014-02-12 00:00:00 (2nd row with 3rd)

  • Opening a view from another view of the same window in diff Browser.

    Hi Experts,
    My requirement is to open a view (say view 2) from another view (say view 1) with click of a button in a different browser, both the views are embedded into the same window, and also i have to pass some data from view1 to view2, based no the input data, i am displaying some information. Also both views belog to the same component.
    Some pointers on this would be of great help.
    Regards,
    Ashish.

    You would need to open another window.
    See if_wd_window and if_wd_window_manager.
    Call the GET_API to get a handle to window manager.
    The new window can show V2.
    The original Window with 2 views,
    must fire plug to navigate v2 to empty view to hide it from Window1.
    The to Views talk to one another via WDC Controller.
    View 2 calls WDC controller methods.  The WDC controller the fires Event.
    View 1 can listen to this event with a method of type event handler.
    View 1 can for example react to button on View 2 and close WINDOW 2.
    Good luck
    Phil.

  • What does it mean when the usecounts of Parse Tree for a view is incrementing when a select query is issued against the view?

    I'm using SQL Server 2008 R2 (10.50.4033) and I'm troubleshooting an issue that a select query against a specific view is taking more than 30 seconds consistently.   The issue just starts happening this week and there is no mass changes in data.  
    The problem only occur if the query is issued from an IIS application but not from SSMS.  One thing I noticed is that sys.dm_exec_cached_plans is returning 2 Parse Tree rows for the view -  one created when the select query is issued
    1st time from the IIS application and another one created when the same select query is issued 1st time from SSMS.   The usecounts of the Parse Tree row for the view (the IIS one) is increasing whenever the select query is issued.  The
    usecounts of the Parse Tree row for the view (the SSMS one) does not increase when the select query is issued again. 
    There seems to be a correlation between the slowness of the query and the increasing of the usecounts of the Parse Tree row for the view.  
    I don't know why there is 2 Parse Tree rows for the view.  There is also 2 Compiled Plan rows for the select query.  
    What does the Parse Tree row mean especially the usecounts column?

    >> The issue just starts happening this week and there is no mass changes in data.  
    There might be a mass changes in the execution plan for several reason without mass changes in data
    If you have the old version and a way to check the old execution plan, and compare to the new one, that this should be your starting point. In most cases you don't have this option and we need to monitor from scratch.
    >> The problem only occur if the query is issued from an IIS application but not from SSMS.
    This mean that we know exactly what is the different and you can compare both execution plan. once you do it, you will find that they are no the same. But this is very common issue and we can know that it is a result of different SETting while connecting
    from different application. SSMS is an external app like any app that you develop in Visual studio but the SSMS dose not use the Dot.Net default options.
    Please check this link, to find the full explanation and solutions:
    http://www.sommarskog.se/query-plan-mysteries.html
    Take a look at sys.dm_exec_sessions for your ASP.Net application and for your SSMS session.
    If you need more specific help, then we need more information and less stories :-)
    We need to see the DDL+DML+Query and both execution plans
    >> What does the Parse Tree row mean
    I am not sure what you mean but the parse tree represents the logical steps necessary to execute the query that has been requested. you can check this tutorial about the execution plan: https://www.simple-talk.com/sql/performance/execution-plan-basics/ or
    this one: http://www.developer.com/db/understanding-a-sql-server-query-execution-plan.html
    >> regarding the usecount column or any other column check this link:
    https://msdn.microsoft.com/en-us/library/ms187404.aspx?f=255&MSPPError=-2147217396.
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Running iTunes 11.0.3 64bit Windows 7. The "join Tracks" line has disappeared from the box that opens when you click "options" after inserting a CD. Only 2 lines show up: "Get track names" and "Submit CD Track names". Where did "Join Tracks" go?

    Running iTunes 11.0.3 64bit Windows 7. The "join Tracks" line has disappeared from the box that opens when you click "options" after inserting a CD. Only 2 lines show up: "Get track names" and "Submit CD Track names". Where did "Join Tracks" go?

    i have the same problem no radio stations at all bit shabby hate technolgy now adays

  • Views using the same offscreen buffer, interfering with each other

    Hi all,
    I am creating an application where I display simulations. In order to keep the view of the simulation ticking along nicely, I paint the view to an offscreen buffer, and then paint the offscreen buffer to the screen.
    This has worked fine for me, so long as I was only viewing one single simulation on the screen at a time. I have now started displaying multiple simulations, and the views have started to interact with eachother -- one will paint over the other, particularly when I click or drag the simulation.
    I'm not using any static variables, so my guess is that the fault is the offscreen buffer that I'm using. I think my various views are using the same buffer. Is it possible that this is the problem?
    Here's how I paint my view:
    private BufferedImage offImg;
    private Graphics2D offG;
    public Graphics2D createGraphics2D(){
              if (offImg != null) {
                   offImg.flush();
                   offImg = null;
              RepaintManager repaintManager = RepaintManager.currentManager(this);
              try {
              offImg = (BufferedImage) repaintManager.getOffscreenBuffer(
                        this, this.getWidth(), this.getHeight());
              } catch (java.lang.NullPointerException e){
                   return null;
              offG = offImg.createGraphics();
              // .. clear canvas ..
              offG.clearRect(0, 0, getSize().width, getSize().height);
              return offG;
    private void draw() {
          if (offG == null)
                   createGraphics2D();
         offG.drawImage(...) //etc
    public void paintComponent(Graphics g){
               g.drawImage(offImg, 0, 0, this);
          }My first thought was to create a list of all the offImg's created and compare them. The different views are indeed getting the same image from repaintManager.getOffscreenBuffer, even though the component passed in as 'this' is different. The offG's created by each view are different, but since they belong to the same image, I assume it's the image that's important.
    Is this likely to be the source of my woes, and, assuming that I want to keep using the offscreen buffer (I do) is there a way around this problem?
    Thanks so much for any advice.

    Hello,
    I am creating an application where I display simulations. In order to keep the view of the simulation ticking along nicely, I paint the view to an offscreen buffer, and then paint the offscreen buffer to the screen.You may know that Swing uses double-buffering by default. So you usually don't really need to tweak Swing's own offscreen buffers.
    Painting conservatively on an applicative offscreen buffer is sounds (if painting is slow), but then your application has to create a dedicated offscreen buffer, not use Swing's ones.
    This has worked fine for me, so long as I was only viewing one single simulation on the screen at a time. I have now started displaying multiple simulations, and the views have started to interact with eachother -- one will paint over the other, particularly when I click or drag the simulation.
    I'm not using any static variables, so my guess is that the fault is the offscreen buffer that I'm using. I think my various views are using the same buffer. Is it possible that this is the problem?I can't tell for sure, but I'm not surprised if that's the case: all Swing ("lightweight") widgets within a same JFrame (or any other "heavyweight" top-level container) share the same native graphical resources, so presumably share the same offscreen buffer. It is Swing's machinery that arranges so that each widget paints onto a part of this buffer that corresponds to the widget's bounds.
              offImg = (BufferedImage) repaintManager.getOffscreenBuffer(
                        this, this.getWidth(), this.getHeight());You don't have to, and probably should not, ask Swing's RepaintManager for a buffer. You vould create a BufferedImage yourself, then draw onto it.
    offImg = new BufferedImage(...);Then your paintComponent method itself is fine:
    public void paintComponent(Graphics g){
               g.drawImage(offImg, 0, 0, this);
    Is this likely to be the source of my woes, and, assuming that I want to keep using the offscreen buffer (I do) is there a way around this problem?See above. And look for "offscreen graphics" on this forums, you'll probably find a lot of examples that do this way (and give example code, my sample above is sketchy and untested).
    Regards,
    J.
    Edited by: jduprez on Jun 2, 2011 12:10 AM
    Read this article if you need to kick the best out of your fast painting code (in particular, it mentions more informed ways than mine to create Image instances suitable for offscreen drawing):
    http://java.sun.com/products/java-media/2D/perf_graphics.html

  • Can we write a join on a view and a table

    Hi all,
    can we write a join on a view and a table. i got the requirement from my functional people about the following one
    Select CAUFV-AFUNR, CAUFV-AUART, AFVC-VORNR, CAUFV-FTRMI, CRHD-ARBPL
    into <ProOrd>, <OrdTyp>, <Opt>, <RelDat>, <WorCen>
    from CAUFV, AFVC, CRHD
    where CAUFV-WERKS = plant in selection screen
    and CAUFV-AFUNR = production order in selection screen
    and CAUFV-AUART = production order type in selection screen
    and CAUFV-FTRMI = range of release date in selection screen
    and CAUFV-AUFPL = AFVC-AUFPL
    and AFVC-ARBID = CRHD-OBJID
    and CRHD-OBJTY = ‘A’
    here CAUFV is a view and CRHD and AFVC are transperent tables.
    please tell me any feasible solution for this..
    Thanks  in Advance..

    Hi
    Refer these links:
    <u>http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ec84446011d189700000e8322d00/content.htm</u>
    <u>http://www.sap-img.com/abap/what-is-the-different-types-and-usage-of-views.htm</u>
    <u>http://www.karakas-online.de/forum/viewtopic.php?t=730</u>
    Thanks
    Vasudha
    Message was edited by:
            Vasudha L

  • Join the same view using 2 different conditions, getting error ORA-00918

    Hi, I am trying to do a full outer join using the same view with different where conditions. Sample code below. I am getting the error "ORA-00918: column ambiguously defined". I have used as much alias as I can on the select statements but it gives me the same error.
    The weird thing is, RIGHT OUTER JOIN and LEFT OUTER JOIN will work fine. Only FULL OUTER gives the error above.
    Thanks in advance for your help.
    SELECT firsttable.<column_name>, secondtable.<columnname>
    FROM
    SELECT ...
    FROM V_MYVIEW
    WHERE <column_name> IN (1,2)
    ) firsttable
    FULL OUTER JOIN
    SELECT ...
    FROM V_MYVIEW
    WHERE <column_name> IN (3,4)
    ) secondtable
    ON firsttable.<column_name> and secondtable.<column_name>

    ON firsttable.<column_name> and secondtable.<column_name> ON firsttable.<column_name> = secondtable.<column_name>

Maybe you are looking for