access to an id in a subselect

Hello

I have the select...

Select x.obj_id

,(Select b.class_id)

from (select a.*

ROWNUM rnum

of (c.obj_class_id select class_id)

of obj_class2 c

where c.obj_classif_id = 5013

and c.obj_id = x.obj_id - 2438087

order of c.obj_class_id

) a

where ROWNUM < = 2

) b

where b.rnum > 1

) value_line_2

of (o.id select obj_id)

to obj o

where o.id in (3208355,3509750,3223514,3452134,3168690)

) x

As you can see, I get an ID called x.obj_id which I want to use in a subselect. The subselect statement returns multiple values, and I want to extract the value 2. But if I try to say c.obj_id = x.obj_id, said oracle x.obj_id is an invalid identifier.

If have tried a lot of things, but in the end I still get the same error. Any suggestions are welcome... of explanations too.

Thanks in advance for your efforts.

Konrad

Hi chris227 and Chris Hunt

Thank you very much for your explanations and suggestions, see the following select statement for a good solution.

As I saw on your answer of my explanations when a little lacking. So, my main selection is, think I catch an obj_id and a large number of attributes of the obj. table a subset other attributes are on other tables that I'll go with the Subselects. It's why I can't do your solutions with the join. But, as you can see it works with the row_number() (c.obj_id of partition by c.obj_class_id order).

I can name this statement of subselect with t and set the condition t.obj_id = x.obj_id which is located on the first level, so I can pick 1, 2. or 3. value, all that I need.

Thanks again for your efforts!

Best regards, Konrad

===================================

Select x.obj_id

x.whatever

.

.

-Subselect for exactly numbered attribute fetch another table, which returns many rows (attributes!). The id on that other table is identical to the id of the main table.

,(Select t.class_id)

of (c.obj_class_id select class_id)

c.obj_id

row_number() over (partition by order of c.obj_class_id c.obj_id) rn

of obj_class2 c

where c.obj_classif_id = 5013

+ 6

where t.obj_id = x.obj_id

and t.rn = 2

) wert_zeile_2

.

.

x.another_value

of (o.id select obj_id)

to obj o

where o.id in (3208355,3509750,3223514,3452134,3168690)--ce code is only for the test!

) x

Tags: Database

Similar Questions

  • Subselect cannot access the key-Select columns?

    Dear experts!

    First of all, I had a pretty simple statement

    SELECT FPS_Main.NACHNAME, FPS_Main.VORNAME, FPG_Main.NAME AS 'Department', FPS_Main.DK_ORGA_BEREICH AS "Orgabereich d. pers.", FPG_Main.DK_ORGA_BEREICH AS "Orgabereich der ABT."
    FPS_Main, GJ FPG_Main FPS
    WHERE FPS_Main.FK_FPG_NR = FPG_Main.PK_FPG_NR
    AND FPS_Main.DK_ORGA_BEREICH = 'AL '.
    AND FPG_Main.DK_ORGA_BEREICH = 'MZ '.
    ORDER BY FPS_Main.NACHNAME

    which produces a table like this:

    First name * first name * Department * organizational field of person * organizational area of the Department
    ...

    I want to add two columns to the statement, the first listing the number of publications of each person for 2008, the second list the number of publications of each person for 2009. I tried to do it like that

    SELECT "Orgabereich der Abteilung", Sub1.Anzahl_2008, Sub2.Anzahl_2009, FPS_Main.NACHNAME, FPS_Main.VORNAME, FPG_Main.NAME AS 'Department', FPS_Main.DK_ORGA_BEREICH AS "Orgabereich d. pers.", FPG_Main.DK_ORGA_BEREICH
    FPS_Main, GJ FPG_Main, FPS)
    SELECT COUNT (FPB_Sub1.FK_FPR_NR) AS Anzahl_2008
    OF THE FPB_Sub1 ASRD, FPR_Sub1, FPN_Sub1 of the RPF, of FPR FPS FPS_Sub1
    WHERE FPB_Sub1.FK_FPR_NR = FPR_Sub1.PK_FPR_NR
    AND FPB_Sub1.FK_FPN_NR = FPN_Sub1.PK_FPN_NR
    AND FPR_Sub1.FK_FPS_NR = FPS_Main.PK_FPS_NR
    AND FPN_Sub1.PUBLIKATION_JAHR = 2008
    ) Sousrepertoire1
    (
    SELECT COUNT (FPB_Sub2.FK_FPR_NR) AS Anzahl_2009
    OF THE FPB_Sub2 ASRD, FPR_Sub2, FPN_Sub2 of the RPF, of FPR FPS FPS_Sub2
    WHERE FPB_Sub2.FK_FPR_NR = FPR_Sub2.PK_FPR_NR
    AND FPB_Sub2.FK_FPN_NR = FPN_Sub2.PK_FPN_NR
    AND FPR_Sub2.FK_FPS_NR = FPS_Main.PK_FPS_NR
    AND FPN_Sub2.PUBLIKATION_JAHR = 2009
    ) Sub2
    WHERE FPS_Main.FK_FPG_NR = FPG_Main.PK_FPG_NR
    AND FPS_Main.DK_ORGA_BEREICH = 'AL '.
    AND FPG_Main.DK_ORGA_BEREICH = 'MZ '.
    ORDER BY FPS_Main.NACHNAME

    using twice the same statement of subselect tabular, but with alias names. But gives me an ORA-00904 - identifier not valid. What I've done wrong, and how I can fix?
    Then I tried like this, with one column first

    SELECT FPS_Main.NACHNAME, FPS_Main.VORNAME, FPG_Main.NAME AS 'Department', FPS_Main.DK_ORGA_BEREICH AS "Orgabereich d. pers.", FPG_Main.DK_ORGA_BEREICH AS "Orgabereich der Abteilung", COUNT)
    SELECT FPB_Sub1.FK_FPR_NR
    THE ASRD FPB_Sub1, RPF FPR_Sub1, NPF FPN_Sub1
    WHERE FPB_Sub1.FK_FPR_NR = FPR_Sub1.PK_FPR_NR
    AND FPB_Sub1.FK_FPN_NR = FPN_Sub1.PK_FPN_NR
    AND FPR_Sub1.FK_FPS_NR = FPS_Main.PK_FPS_NR
    AND FPN_Sub1.PUBLIKATION_JAHR = 2008
    )
    FPS_Main, GJ FPG_Main FPS
    WHERE FPS_Main.FK_FPG_NR = FPG_Main.PK_FPG_NR
    AND FPS_Main.DK_ORGA_BEREICH = 'AL '.
    AND FPG_Main.DK_ORGA_BEREICH = 'MZ '.
    ORDER BY FPS_Main.NACHNAME

    give me an ORA-00936 - lack of expression. I never tried to use a (sub) - SELECT within an aggregate function, but I have seen somewhere else and thought it might be a good idea for this case, but seems its does not work - what is wrong here?

    I thank very you much in advance!

    With sincere friendships.
    Chriss

    You need a pair of Klammern around your subselect:

    SELECT   FPS_Main.NACHNAME, FPS_Main.VORNAME, FPG_Main.NAME AS "Abteilung",
             FPS_Main.DK_ORGA_BEREICH AS "Orgabereich d. Pers.",
             FPG_Main.DK_ORGA_BEREICH AS "Orgabereich der Abt.",
             COUNT((SELECT FPB_Sub1.FK_FPR_NR
                      FROM FPB FPB_Sub1, FPR FPR_Sub1, FPN FPN_Sub1
                     WHERE FPB_Sub1.FK_FPR_NR = FPR_Sub1.PK_FPR_NR
                       AND FPB_Sub1.FK_FPN_NR = FPN_Sub1.PK_FPN_NR
                       AND FPR_Sub1.FK_FPS_NR = FPS_Main.PK_FPS_NR
                       AND FPN_Sub1.PUBLIKATION_JAHR = 2008))
        FROM FPS FPS_Main, FPG FPG_Main
       WHERE FPS_Main.FK_FPG_NR = FPG_Main.PK_FPG_NR
         AND FPS_Main.DK_ORGA_BEREICH = 'AL'
         AND FPG_Main.DK_ORGA_BEREICH = 'MZ'
    ORDER BY FPS_Main.NACHNAME
    

    URS

  • ORDER BY in the subselect, then a join

    I had a difficult time in the research on this or even prove it so I came to the forum asking for advice.

    My question is how Oracle will take care of the scheduling of a query in which I

    SELECT *
      FROM (  SELECT *
                FROM (    SELECT LEVEL c1,
                                   LEVEL
                                 * TRUNC(DBMS_RANDOM.VALUE(1,
                                                           4))
                                    val_rnd
                            FROM DUAL
                      CONNECT BY LEVEL <= 200)
            ORDER BY c1 ASC) a,
           (    SELECT TRUNC(  LEVEL
                             * DBMS_RANDOM.VALUE(1,
                                                 4))
                          val_rnd2
                  FROM DUAL
            CONNECT BY LEVEL <= 200) b
     WHERE a.c1 = b.val_rnd2(+)
    

    In this case, my subselect is the order of the ascendants of c1. That part I understand, and I'll do my subquery 'a' ordered to become. My next step then joins this request sorted to a second table ('b').

    In this join, Oracle always preserves my initial sort or do I need to add a second order by a.C1 ASC after the join to guarantee that she will return in a sorted order.

    My example above returns the query how I want that it but I can't tell if it's just because of me be lucky and Oracle return correctly or if it will be guaranteed 100% function this way.

    I'm running on Oracle 11.2.0.4

    Oracle can transform your query into something that is easier to optimize, but with the same semantics. Being the ORDER BY in a view online, I guess that Oracle could even decide to ignore it (although I'm not sure of this point) - as Justin and Frank write already: only an ORDER BY in the main query will give you the 100% guarantee. If I run your query to 11.2.0.1 plan is:

    ----------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ----------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |      |     1.    39.     6 (34) | 00:00:01 |

    |   1.  SORT ORDER BY |      |     1.    39.     6 (34) | 00:00:01 |

    |*  2 |   OUTER HASH JOIN |      |     1.    39.     5 (20) | 00:00:01 |

    |   3.    VIEW                         |      |     1.    26.     2 (0) | 00:00:01 |

    |*  4 |     CONNECT TO WITHOUT FILTERING.      |       |       |            |          |

    |   5.      QUICK DOUBLE |      |     1.       |     2 (0) | 00:00:01 |

    |   6.    VIEW                         |      |     1.    13.     2 (0) | 00:00:01 |

    |*  7 |     CONNECT TO WITHOUT FILTERING.      |       |       |            |          |

    |   3 ×      QUICK DOUBLE |      |     1.       |     2 (0) | 00:00:01 |

    ----------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    2 - access("from$_subquery$_002".") C1 '=' B '. "VAL_RND2" (+)) "

    4 filter (LEVEL<>

    7 filter (LEVEL<>

    So we can see that Oracle made a transformation and moved the SORT ORDER BY in subquery: with this plan, you get the correct order - but there is no guarantee that the Oracle will use this plan (and transformation) in different versions / with different settings etc.

  • Access denied... Apple Support pages

    Someone else gets this error on Apple Support Pages?

    alexbird wrote:

    Someone else gets this error on Apple Support Pages?

    first time I saw it.  How do you access the support page?

  • Since iOS 10.0.2 my phone is accessible without the access code

    Since iOS 10.0.2 my phone is accessible without the access code after I pressed the sleep button. Press the home key several times my phone opens. As a first step, it is that he fell asleep in itself not when I used the sleep button but now even after skeep button I can access my phone without the password.

    the rear power and apple support site are not easy to use to report the problem.

    Have you tried to set up your password again in the settings?

  • How to download to iCloud for iOS for offline access device

    How can I download a file from iCloud drive iPhone 6 for offline access?

    The file would need an app to run in.  For example, a Word file could run in the application of the word iOS.  What kind of file is it?

  • Cannot access netflix account on macbook

    I have an account with netflix via iTunes. I want to access it on my macbook. How can I do this?

    Have you tried to go directly to the site?

    http://www.Netflix.com/

  • Access code is lost as soon as the screen turns off

    When I turn my wrist after that my Apple Watch screen exploded, I need to enter the access code. I turn on the wrist, the screen turns off, I turn back, screen lights up, I need to re-enter the password. And so on and so forth. The watch does not maintain the code.

    I am white white, is not dense hairs on my wrist, no tattoos and I wear the watch very well on my skin.

    The funny thing is: it is a replacement watch, I got today. The other had the same problem, but this is probably because the bottom of the watch with the sensors fell, must have damaged the sensor cable. But this one is brand new.

    Hello

    Make sure the wrist detection is enabled:

    • On your iPhone, in the application of the watch, go to: My Watch (tab) > General > detection of wrist - turn on.
  • iTunes on pc does not recognize my iphone. the pc does. the iphone asks me to allow access to what I do

    iTunes on pc does not recognize my iphone. the pc does. the iphone asks me to allow access to what I do

    Hello

    Check this help page: If iTunes does not your iPad, iPhone or iPod - Apple Support

  • Someone tries to access my Apple account?

    I sang in my Apple ID on my mac, type in the verification code 2 step and everything was good, bit I disconnected. I went and looked at my iPhone and it had notification of two steps and asked if I wanted to allow. I clicked No. and changed my password because I was already burnt out on my mac. Someone tries to access my Apple account? little freaked out.

    No, it's ok.

    Frequently asked questions about the audit in two steps for Apple ID - Apple Support

  • How can I access Siri on my iMac without using the icon?

    How can I access Siri on my iMac without using the icon?  Can I say "Hey Siri"?

    There is no option "Hey Siri" on a Mac because they do not have the necessary pickups. You must use the icon in the menu bar or Dock.

  • Access ICloud and functionality issues

    I have a continuous problem that my guard unit invites me to update my iTunes password. I've updated several times by resetting the password. I am still unable to access the features in iCloud.

    This - see difficulty constant Apple ID verification password pop up

  • Cannot access through its name WD my cloud

    Hi, I am using OSX Seira. I try to connect to my WD my cloud device by using the name of the device via its app, but can not access. But when I use the IP address of my cloud, I can access it easily. It is also perfectly show in Finder.

    Can someone guide me why can not use it by name?

    Ignore it. When I rebooted the WD my cloud device. It works fine now. Don't know why this has happened.

  • Woman updated its iPAD Pro 10.0.2 and is now locked screen display "Enter Access Code, contact ID requires your access code when you restart the iPad." She has no idea what is an "access code". Any help is appreciated.

    Woman updated its iPAD Pro 10.0.2 and is now locked screen display "Enter Access Code, contact ID requires your access code when you restart the iPad." She has no idea what is an "access code". Any help is appreciated.

    If she don't remember: If you have forgotten the password for your iPad, iPhone or iPod touch, or your device is disabled - Apple supports

  • How to access confidential information stored in my Mac?

    I would like to delete a password from the memory of my computer, but have no idea how find the list. Can anyone help please.

    Use the Keychain Access application located in the Utilities folder.

Maybe you are looking for

  • LabVIEW 2009 is no longer, you can unlock an automatic selection tools

    I just connected a new CAR for 2009 that I publish not normally (too many), but a lot of the Tabbers won't like this one. Hey Ben, Bug # is 182903: In LabVIEW 8.6 under Tools > Options > environment, there is a check box "lock automatic selection of

  • HP Envy 4500: HP Envy 4500 cannot print in Windows 7

    I bought a new HP ENVY 4500 printer a few days ago and I am having the problem of can't even print a test page from Windows 7 Printer Device Properties with an error message of "Page of Test failed print" and followed the printing result advocatus of

  • Windows vista crash

    I need help, I have retarted my computer once you have downloaded the service pack of windows vista, but after that I went to reactivate it with system has changed and I need to insert the windows installation disc, but my computer was pre installed,

  • I have problem with the escape key

    I have the problem with the ESC key... is sometimes from time to time I press my ESC key on my labtop that he would open to the top of my Start menu... there at - it a config that I can turn it off?  Sometimes I play computer game it just annoying so

  • Full administration must off UAC?

    On another forum has a photo editing software for some tech support person tell everyone that they must stop their UAC before running a program with admin access because it's the only way to get full admin access. Is this correct? UAC prevents still