Issue with Multilevel subquerying, correlating out and inner object failing

Hi,
I have a peculiar situation with no idea how to overcome this. Please consider the following example.
I have Table T1 with columns C1 , C2 , C3 and Table T2 with columns D1, D2, and D3.
Here i need to fetch the column C1 and D1 when C2 = D2 or when C3 = D3 and D2 = null. So I wrote a query
Select t1.C1, (select D1 FROM T2 t2 WHERE (t2.D2=t1.C2) OR (t2.D3 = t1.C3 AND t2.D2 is null))
FROM TABLE T1 WHERE t1.C1 = 123456
But here the problem was when I have two records maintained that will satisfy the condition I add a selected around the inner select with the where clause having rownum = 1
ie
Select t1.C1, (select D1 FROM
(select D1 FROM T2 t2 WHERE (t2.D2=t1.C2) OR (t2.D3 = t1.C3 AND t2.D2 is null) order by t2.D2, t2.D3) b
WHERE rownum = 1)
FROM TABLE T1 WHERE t1.C1 = 123456
The reason for taking the rownum outside was that i need to fetch the record where D2 is not null if it is present, therefore forcing me to use an order by clause. If I use rownum in the same inner query it fetches the first row before the order by clause is applied to the result.
But now the problem is that i am getting an error that says t1.C2 and t1.C3 are invalid identifiers. How do i overcome this?

Hi,
I am not able to clearly understand your requirement, neither there is any reference data.
Anyways, based on what i could think, I have made the below query, think you can tweek it to suit your requirement.
SQL> CREATE TABLE t1 (c1 NUMBER, c2 NUMBER, c3 NUMBER);
Table created
SQL> CREATE TABLE t2 (d1 NUMBER, d2 NUMBER, D3 NUMBER);
Table created
SQL> INSERT INTO t1 VALUES (1 ,2, 3);
1 row inserted
SQL> INSERT INTO t1 VALUES (4, 5, 6);
1 row inserted
SQL> INSERT INTO t1 VALUES (7, 2, 3);
1 row inserted
SQL> INSERT INTO t2 VALUES (1, null, 3);
1 row inserted
SQL> INSERT INTO t2 VALUES (1, 2, 3);
1 row inserted
SQL> INSERT INTO t2 VALUES (4, 5, 6);
1 row inserted
SQL> INSERT INTO t2 VALUES (4, 5, 6);
1 row inserted
SQL> SELECT c1, c2, c3, d1, d2, d3
  2    FROM (SELECT t1.c1,
  3                 t1.c2,
  4                 t1.c3,
  5                 t2.d1,
  6                 t2.d2,
  7                 t2.d3,
  8                 ROW_NUMBER() OVER(PARTITION BY t1.c1, t1.c2, t1.c3, t2.d1, t2.d3 ORDER BY t2.d1, t2.d2, t2.d3) rn
  9            FROM t1, t2
10           WHERE (t1.c2 = t2.d2)
11              OR (t1.c3 = t2.d3 AND t2.d2 IS NULL))
12   WHERE rn = 1
13  /
        C1         C2         C3         D1         D2         D3
         1          2          3          1          2          3
         4          5          6          4          5          6
         7          2          3          1          2          3
SQL> Regards
Ameya

Similar Messages

  • Ipod nano 7th generation having issues with the UI. Out of box everything worked great. Once I snyc the device and it finished, the UI becomes unuesable. You have to double tap every icon in order to open music, videos, etc.  I cannot swipe to the second

    ipod nano 7th generation having issues with the UI. Out of box everything worked great. Once I snyc the device and it finished, the UI becomes unuesable. You have to double tap every icon in order to open music, videos, etc.  I cannot swipe to the second page of icons,  black box appears around an icon and then switches to a different one anytime I swipe. A box even appears around the time and battery power. iPod & iTunes are both updated. What is the FIX on this issue?

    I had this problem as well.  This is what I found by searching online.  I tried the fix on my nano 7th gen and it worked.  I hope this helps you.  Make sure to use two fingers for sliding and double-click the icons to get into settings.  Good luck.
    It would seem that Voiceover has been enabled on your iPod Nano. The following article contains information regarding Voiceover, and how to disable it once it's been enabled.
    iPod nano (6th generation and later): How to use VoiceOver
    http://support.apple.com/kb/HT4317
    To turn off VoiceOver on iPod nano using VoiceOver gestures
    From the Home Screen, swipe right or left with two fingers until you see or hear "Page 2 of 2" on iPod nano (7th generation) or "Settings" on iPod (6th generation).
    If the icons have been rearranged, or if there are more than four Home screens, you may hear something different.
    Slide one finger around the screen until you hear Settings. 
    Double-tap to open Settings. 
    Slide your finger up or down the screen until you see or hear General, then double- tap. 
    Slide your finger up or down the screen until you see or hear Accessibility, then double-tap. 
    Slide your finger up or down the screen until you see or hear VoiceOver, then double-tap. 
    Double-tap when you hear "VoiceOver switch button on." 
    You'll hear "VoiceOver off" to confirm the setting. Now you can use standard gestures to control iPod nano.
    Note: You can also turn off VoiceOver by resetting your iPod.

  • Is anyone else having issues with Lightening cables wearing out fast

    Is anyone else having issues with Lightening cables wearing out fast

    It does happen.  Search Google and you will find many instances.

  • I like and use Top Sites but it has become unsuable with this constant blacking out and reloading the thumbnails.  My MBP has not seen a problem at all.   I have been searching every other day for over a month trying to find a fix in Windows Safari with n

    I like and use Top Sites but it has become unsuable with this constant blacking out and reloading the thumbnails.  My MBP has not seen a problem at all.
    I have been searching every other day for over a month trying to find a fix in Windows Safari with no joy.  I want to resolve, not switch browsers. Please offer up a solution that only refreshes the Top Site thumbnails once a day or as some controlable interval.  Started about two versions ago, now on ver 5.1.5. Windows 7 64bit.
    Safari 5.1.5 for Win64 bit, Windows 7!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    I think I solved the wifi connection problem, just by switching off completely the router! sounds trivial, but in this case it worked!!!
    the funny behaviour of the trackpad/cursor still persists. any suggestion???
    thanks again

  • OSX 10.9.1 Compatibility issue with Sharp Aquos PN-L702B and PN-L802B

    I have Mac Mini's connected to the Sharp Aquos PN-L702B and PN-L802B touch screens and after updating to 10.9.1 am experiencing what appears to be a compatibility issue with the Sharp TPM driver and the OSX 10.9.1.  
    Everything works perfectly previously on 10.8.4 and 10.8.5.  I did not test on 10.9.0 as I went straight to 10.9.1.  Anyone else having this problem?  Any thoughts on resolution?

    OK so perserverance seems to have helped here - i used the cmd R function on start up to get to the page where i can re install OS X Lion - Safari now working.
    However i have Office 2011 for MAC and now Excel wont start so i will post on another thread for help with this
    Hope this helps if anyone has a similar issue

  • Issue with Acrobat 10.1.2 and Windows 7 64-bit Preview Handler

    Hi. I work in an enterprise environment that is currently migrating to  64-bit Windows 7. The only version of Acrobat we have approved for Windows 7 is 10.1.2. We're seeing an issue with this version that causes the preview handler to not work. The preview panel in Explorer is just white and will eventually give the error "Preview handler surrogate host has stopped working."  I've tried to fix listed on http://www.pretentiousname.com/adobe_pdf_x64_fix/index.html but that registry key is already correct. Our current work around for these users to just install Reader X1 and make it the default PDF handler, but I would like to find a better solution. Is there a known issue with Acrobat 10.1.2 and 64-bit operating systems? Or is there a way to change just the default preview handler?

    Most of the info on the web page you link to is 2-4 years old. I doubt it applies. Your workaround is actually the best solution: It's always preferred to use the latest PDF viewer. Reader and Acrobat can exist on the same machine.
    Also, why 10.1.2? There have been 6 releases since then with documented security enhancements (meaning there are also published vulnerabilities which are patched), bug fixesm, and feature enhancments.
    I'll ping some folks about the error you are getting. . .
    hth,
    Ben

  • Are there any issues with using OS X Mavericks and Premiere CC?

    Are there any issues with using OS X Mavericks and Premiere CC?

    Official statement: http://blogs.adobe.com/premierepro/2013/10/premiere-pro-and-mac-os-x-10-9-mavericks.html
    Peter Garaway
    Adobe
    Premiere Pro

  • Issue with Adobe Encore CS5.1 and Matrox MAX H.264 encoding on Windows

    Here's some information on an issue that we've identified with Matrox products and Encore CS5.1:
    "Issue with Adobe Encore CS5.1 and Matrox MAX H.264 encoding on Windows"

    Still flickering on Encore even when rendered in MPEG-2 DVD in Pemiere Pro CS5.5. Looks perfect in Premiere Pro.
    Any other ideas?
    EDIT: Was looking for Google for people with similar problems to me and I came across this http://forums.adobe.com/message/3959757?tstart=0
    I am currently re-rendering the video in PAL DV Widescreen MPEG-2 DVD and using maximum render quality.

  • Are there ANY compatibility issues with Itunes 12.0.1 and Mavericks?  Don't want to download Yosemite.  Not hearing good things about it.

    Are there ANY compatibility issues with Itunes 12.0.1 and Mavericks?  Don't want to download Yosemite.  Not hearing good things about it.  I'm on Mavericks 10.9.5.

    one obstacle, quickly removed. thank you.
    nomenclature aside for a moment, 10.6.8 is correct but maybe more is necessary about the MacBook Pro: it is 'old': Identifier: 1.2, Intel Core Duo, 2.16 GHz, 1 Processor, L2 2 MB, RAM 2 GB.
    i hope that is enough to get an answer to this: is it unadvisable to update its OS; in other words, if i update to 10.9, will the machine be able to handle it, 'speedwise'?

  • I have Calendar v 7.0 and Entourage 12.3.6 2008 on OS X 10.9.2. I cannot import Entourage events into Calendar - this was never an issue with iCal. Whats happened and how can I import details into Calendar or do I need iCal back?

    I have Calendar v 7.0 and Entourage 12.3.6 2008 on OS X 10.9.2. I cannot import Entourage events into Calendar - this was never an issue with iCal. Whats happened and how can I import details into Calendar or do I need iCal back?

    adamboettiger wrote:
    Sophos and MacKeeper
    There are many reported problems with both these programs.
    Run through this list of fixes in order, will tune you right up.
    They are in order for a reason.
    ..Step by Step to fix your Mac

  • HT1600 turned my Apple TV on and get continuos flashing light, on my tv I get a picture of Apple TV unit with a cable coming out and a large iTunes icon

    turned my Apple TV on and get continuos flashing light, on my tv I get a picture of Apple TV unit with a cable coming out and a large iTunes icon

    http://support.apple.com/kb/HT4367?viewlocale=en_US&locale=en_US

  • I am having multiple issues with syncing my iphone calendar and outlook There are often 1 hour time differences in the entries on the 2 devices and sometimes events that have been amended are not updated on iphone I mostly enter items on my laptop

    I am having multiple issues with syncing my iphone calendar and outlook calendar on my laptop
    I mostly enter the original items on my laptop
    There are often 1 hour time differences in the entries on the 2 devices and sometimes events that have been amended are not updated on iphone

    This sounds like an error in Time Zone support. The time zone needs to be the same in Outlook as well as the phone.

  • Issue with Visibility Settings for Backgrounds and Layers

    I am using Acrobat Pro XI 11.0.10 (Windows) and having an issue with visibility settings for layers and backgrounds. I am attempting to get backgrounds to appear while viewing in Adobe Reader and Acrobat Pro but not be printed and so far have had no success.
    When using a background the Appearance Options dialogue has "Show when printing" unchecked, but "Show when displaying on screen" is checked. This results in the background not showing on the screen, and the background will only appear once the box for "Show when printing" is checked. It looks like the option for printing is dictating whether or not the background is able to appear.
    Using layers has not worked either. The background layer is set to "Never Prints", but will still show up when printed.
    I was wondering if anyone else has run into this and has a solution, or has any recommendations.
    Thanks in advance.

    Hi setrev2012,
    How are you adding the backgroud?
    The only way I can think to accomplish this is via a watermark.
    The basics...
    Open PDF in Acrobat. Choose Pages > Watermark > Add Watermark.
    Select a jpg or PDF of your background and adjust scaling options as desired.
    Then click the Appearance Options.. and uncheck the Show When Printing option.
    In this image the PDF is a blank page with the word "Test" on it. The watermark is the stamp and impression (a stock photo jpg).
    If you want a solid color background, just create a flat image of the background color for use as the watermark.
    If you have already followed the steps and still facing the issue then please share the file with me at [email protected] so that i can have a look.
    Regards,
    Rave

  • Problem with Outer and Inner Classes....or better way?

    Right now I'm trying to create an Inner class.
    My .java file compiles ok, and I create my jar file too.
    But when I try to instantiate the Inner class, it fails:
    java.lang.NoClassDefFoundError: com/myco/vlXML/vlXML$vlDocument.
    Here's the class code:
    public class vlXML{
        private ArrayList myDocList=new ArrayList(); //holds documents
        public vlXML(){
        private class vlDocument{
            public vlDocument(){
            //stuff goes here
        public vlDocument vlDOC(){
            return new vlDocument();
        public void addDocument(){
            vlXML xxx=new vlXML();
            vlDocument myDoc=xxx.vlDOC();
            myDocList.add(myDoc);
        public int getNumDocs(){
            return myDocList.size();
    }Then, from a jsp page, I call:
    vlXML junk1=new vlXML();
    junk1.addDocument();...and get the error...
    Can someone help me figure out why it's failing?
    Thanks....

    You nailed it - thanks....(duh!)
    While I have your attention, if you don't mind, I have another question.
    I'm creating a Class (outer) that allows my users to write a specific XML file (according to my own schema).
    Within the XML file, they can have multiple instances of certain tags, like "Document". "Document"s can have multiple fields.
    Since I don't know how many "Documents" they may want, I was planning on using an Inner Class of "Document", and then simply letting them "add" as many as necessary (thus the original code posted here).
    Does that seem like an efficient (logical/reasonable) methodology,
    or is there there something better?
    Thanks Again...

  • Loaded Creative Cloud 8 days ago. Bought photoshop and lightroom. Downloaded no issues with Lightroom, photoshop errors out each time I open it. Installed on Windows 7

    I have been running Photoshop 8 for years. Upgraded from Vista to Windows 7 just so I could get Lightroom. I am paying the 9.99/mth for Lightroom and photoshop. I downloaded and am already using Lightroom. When I try to open photshop it will open, but when I go to file to try and select a photo, it errors out and says looking for solution and to close program. Totally frustrated

    Holy cow.  Victoria, if I could reach through the internet and give you a cupcake I would!  That worked! 
    It's amazing -- I sat on chat with customer support for 3 hours, and they weren't able to come up with the solution.  He had me creating new accounts, wiping out various directories, changing read and write permissions here and there, searching for non-existant files, and yes, repeatedly installing from disc and from download, and nothing worked.  I've been searching the internet up and down, and there are some really involved "solutions" out there for this problem. 
    Thanks for finallly guiding me to a solution! 

Maybe you are looking for