Results of the query variant with unused table in the from clause

Hi all

I (processing_table2) table specified in the FROM clause in the SQL query , but I have not used any of its value in the SQL statement , but it still affects the results of the query. Please help me out here I'm naïve.

This is the provided query

SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)

OF crev revenue_lines,.
cssp sales_split,
processing_table2
WHERE crev.order_num = '7631090072'

Results of the above query : 344028065018.359



SELECT

Sum((CREV.sadc_extd*CSSP.redit_pcnt)/100)

OF crev revenue_lines,.
sales_split PCSS

WHERE crev.order_num = '7631090072'

Results of the above query : 26463697309.1046


Someone here suggest me pls!

924804 wrote:
Hi all

I (processing_table2) table specified in the FROM clause in the SQL query , but I have not used any of its value in the SQL statement , but it still affects the results of the query. Please help me out here I'm naïve.

This is the provided query

SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)

OF crev revenue_lines,.
cssp sales_split,
processing_table2
WHERE crev.order_num = '7631090072'

Results of the above query : 344028065018.359

SELECT

Sum((CREV.sadc_extd*CSSP.redit_pcnt)/100)

OF crev revenue_lines,.
sales_split PCSS

WHERE crev.order_num = '7631090072'

Results of the above query : 26463697309.1046

Someone here suggest me pls!

CARTESIAN PRODUCT of the changes result set

Tags: Database

Similar Questions

  • Insert the result of a query select in another table

    Hello

    I have a strange problem when I try to insert all the results of a query select in another table, using the declaration of the order.

    With the declaration of COMMAND it works fine
    Work:
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". ' ' 'ACTIONS');
    ------------------------------

    But if I try to sort the result using the declaration of the ORDER, I have the following error:
    Error: ORA-00907 missing right parenthesis
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". "" "ACTIONS"
    ORDER BY
    "STOCK". ("' CODART_STO ASC ');
    ------------------------------

    Any idea?

    Thank you for your help,
    Angel.

    delete "()" to select

    create table test1 (a number, b varchar2(100));
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101;
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101 order by to_char(sysdate - level, 'D');
    
    select * from test1;
    
    drop table test1;
    
  • Effect of an additional table in the FROM clause in the query results?

    I recently helped a colleague debug one of their SQL statements

    The output was showing some very unexpected totals, and I was able to shrink down to an additional table in the FROM clause, but not used anywhere else in the application.

    Thus, for example

    SELECT A.ID, B.CODE
    Of
    EMPLOYEE,
    B OF THE STATUTE,
    PAY THE SAL
    WHERE A.ID = B.ID
    AND
    A.ID = 1;

    I was wondering, how can an extra table in a FROM clause influence directly on the rest of the query?

    The query above is just an example of what I've seen, the my co worker was working on is a bit larger and a lot more code to read. I noticed that when I added/removed the extra table in my query to co workers and then it worked as expected.

    I always thought that an additional table is not attached to what anyone would be just to do the inefficient code, but does not affect output
    just do the inefficient code

    Yes, that too, you will get a Cartesian product by calling is not the entries in the where clause for this table 'disappeared' :(

  • Number of tables in the from clause

    Hello
    Can someone tell me how many tables can we have clause in oracle.

    As you can see it

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14237/limits003.htm#i288032

    Subqueries levels Maximum of subqueries in a unlimited SQL in the FROM clause in subqueries queries Top Level 255 in the WHERE clause

    Subqueries in the FROM-> unlimited, so number of tables is also unlimited (limited only by the size of SQL and probably time of your life while waiting to join thousands of tables :)) results

  • A subquery in the From Clause

    How can I model the RPD with the sub query that has the subquery in the from Clause.

    SELECT

    o948938. CONSOLIDATED_NAME,

    (SUM (o948992. YTD_COMPLETED)) / (SUM (TOTAL_OCC_AP)) AS C_1,.

    SUM (TOTAL_OCC_AP) AS TOTAL_OCC_AP,

    Of

    ORG_DIM o948938,

    TIME_MONTHLY_DIM o948963,

    INSPECTION_FACT o948992,

    (SELECT TDS_NUM,

    MONTH_ID,

    SUM (TOTAL_APTS) TOTAL_AP,

    OF SUMMARY_FACT

    TDS_NUM GROUP,

    MONTH_ID

    ) O949126

    WHERE (o949126. MONTH_ID = o948992. MONTH_ID (+)

    AND o949126. TDS_NUM = o948992. TDS_NUM (+)

    AND (o948938. TDS_NUM = o949126. TDS_NUM)

    AND (O948963. MONTH_ID = O949126. MONTH_ID))

    Group

    O948938. NEW_BOROUGH_GROUPING

    Hello

    You can do this via an opaque view.

    You can also do this by modeling the cumulative value as a calculation LOGIC in the group by aggregation "pinned" to a specific dimension hierarchy that reflects consolidation in the online posting.

    Hope this helps,

    Robert.

  • Question on the use of expressions and aliases in the FROM clause

    Hello

    I have the following query
     select substr(e.ename, iter.pos, 1) as C
       from (select 'KING' as ename from dual) e,
            (select rownum as pos from dictionary where rownum <= 100) iter
      where iter.pos <= length(e.ename);
    outputs (of your choice):
    C
    -
    K
    I
    N
    G
    For the purposes of hardcode 'KING' was made for the test, IRL would be a column from other tables. Is the other piece that is hardcoded "where rownum < = 100 ' and it's the one I would like to find a way to remove.

    I tried the following:
     select substr(e.ename, iter.pos, 1) as C
       from (select 'KING' as ename from dual) e,
            (select rownum as pos from dictionary where rownum <= length(e.ename)) iter
      where iter.pos <= length(e.ename);
    Unfortunately this does not work because the SQL parser has not analyzed enough of the FROM clause to know e.ename causing the length (e.ename) expression return a message identifier unknown.

    I tried to restructure the query above to make the SQL parser aware of the e.ename early enough and therefore accept it. My efforts have failed.

    I would like to know if there is a way to restructure the statement length (e.ename) can be used instead of Hardcoding an artificial upper limit (for example 100 as in the first statement).

    Thank you

    John.

    Use CONNECT BY LEVEL:

    SQL> select substr(ename, level, 1)
      2  from ( select 'KING' ename
      3         from   dual
      4       )
      5  connect by level <= length(ename);
    
    S
    -
    K
    I
    N
    G
    
    4 rows selected.
    
  • Query SQL with multiple tables - what is the most effective way?

    Hello I learn PL/SQL. I have a simple procedure, where I need to find the number of employees and departments by location according to location_id user input.

    I have 3 Tables:

    LOCATIONS
    Location_id (pk)
    location_name
    ...
    DEPARTMENTS
    department_id (pk)
    Location_id (fk)
    department_name
    ....
    EMPLOYEES
    employee_id (pk)
    department_id (fk)
    Employee_Name
    ....

    1 location can have 0 - SEVERAL departments
    1 employee has 1 Department

    Here's the query I come up with for PL/SQL procedure:

    / * Ecount, Dcount are variable NUMBERS * /.

    SELECT SUM (EmployeeCount), COUNT (DepartmentNumber)
    IN Ecount, Dcount
    Of
    (SELECT COUNT (employee_id) EmployeeCount, department_id DepartmentNumber
    Employees
    GROUP BY department_id
    HAVING department_id IN
    (SELECT department_id
    Ministries
    WHERE location_id = userInput));

    I get the correct result, but I wonder if my query is on the right track and if there is a more "efficient" method to do so.
    Thanks in advance for help a beginner.

    Hello

    Welcome to the forum!

    Something like this will be more effective:

    SELECT    COUNT (employee_id)               AS ECount
    ,       COUNT (DISTINCT department_id)     AS DCount
    FROM       employees
    WHERE       department_id IN (     SELECT     department_id
                        FROM      departments
                        WHERE      location_id = :userInput
                      )
    ;
    

    You should also try a join instead of the IN subquery.

    For efficiency, do only the things you need to do.
    For example, you need not a number of employees in each Department, in order to not calculate one. This means that you will not need the notice online, so do not have.
    You needn't PL/SQL for this work, so don't use PL/SQL, if you do not have to (I know this question was out of context, then you may have good reasons to do this in PL/SQL.)

    Perform all the filtering as soon as possible. Do not waste it effort on the things that will not be used.
    An example of this is: never use a HAVING clause when you can use a WHERE clause. What is the difference between a WHERE clause and a HAVING clause? The WHERE clause is applied until the aggregate functions are calculated and the HAVING clause is applied after; There is no other difference. Therefore, if the HAVING clause is not reference an aggregate function, it could be done in a WHERE clause instead.

  • How to put the subquery in the from clause

    Hi all

    I want to put a my from clause subquery. I want to show the details of an account, when the status is active, but I want to show the date when he opened.

    Here is my report query.

    Select t.acct_id, x.acct_status_Dt
    of cust_acct t, (select t1.acct_id, t1.acct_status_Dt from t1 cust_acct where t1.acct_status_code = 'OPEN') x
    where t.acct_id = x.acct_td
    and t.acct_status_code = 'ACTIVE'

    Someone knows how to impliment this kind of query in OBIEE without RPD Exchange.

    Help, please...

    Hello

    To be more clear, ask in the Advanced tab of the request, should look like:

    select A.saw_0, x.saw_1 from (select acct_id saw_0 from cust_acct)A, (select acct_id saw_0, acct_status_Dt saw_1 from cust_acct where cust_acct.acct_status_code='OPEN') x
    where a.saw_0=x.saw_0
    

    Actual query that you pasted:

    select t.acct_id,x.acct_status_Dt
    from cust_acct t , (select t1.acct_id, t1.acct_status_Dt from cust_acct t1 where t1.acct_status_code='OPEN') x
    where t.acct_id= x.acct_td
    and t.acct_status_code='ACTIVE'
    

    I think it is x.acct_id in where clause... not x.acct_td, I corrected and wrote the sql above...

    Published by: Kishore Guggilla, July 17, 2009 12:00

  • * Dynamic * Table name in the From Clause, with the help of the cursor

    Hello
    I said a slider...
    Select the table table_name from dba_tables where < blah >
    The result is
    Row1: emp
    rwo2: emp_1-> tables have the same structure and quite different data... Please don't ask why it's like that, and we can not change...

    Now, we need to run an Insert...

    Insert into tableX (col1, col2,...) select a, b,... from < o/p of the cursor > where < blah >...
    Note: The table changes name and it the cursor can o/p emp, emp_a and emp_b.

    Trying to do at the same time instead of do series and with the best performance... .no sql injection issues.
    In parallel, I mean
    Insert into tableX (col1, col2,...) select a, b,... from emp where < blah >
    and insert tableX (col1, col2,...) select a, b,... from emp_1 where of < blah > statements at the fire parallel / at the same time to the database. If you can share the procedure if you guys already have with you... is really appreciated

    Thank you very much for your time...

    Published by: user007009 on April 27, 2013 20:33

    >
    because suppose each request took 10 minutes and we have 5 tables, then 50 minutes so executed in series and 5 minutes, if each of them both right... I'm saving this time
    >
    And that's what I'm talking about when I said that
    >
    what you're doing wrong is trying to implement solutions more possible complex for a problem that does not exist yet.
    >
    You do not HAVE a problem. You are just "assuming"; "Suppose that each query took 10 minutes... ».

    Well suppose that the time it takes to "chunk" the query, run it in parallel is longer than the time it takes to simply run the query. Oh, wait, that OF what you have discovered.

    Well, let's assume that each query took 2 seconds. Assume that all this takes that half a second. Suppose you waited until you actually have a problem.

    The solutions are to solve real problems, not imaginary and non-existent problems.

    If all you are doing is "assume that" you will never find a 'solution' because you could always 'suppose' another problem that prevents this 'solution' of work.

  • NUMBERS FROM 1 TO 300 WITH THE HELP OF THE TABLE 'DOUBLE' IN FROM CLAUSE

    Hi masters.

    I need display numbers from 1 to 300.
    We can achieve this by
    Select rownum from TABLE_NAME where ROWNUM < = 300;

    But the need to display table DOUBLE...

    Try this:

    SELECT the level "Numbers."
    OF the double
    CONNECT BY LEVEL<=>

  • Two variables in the name of a table in the FROM clause.

    Hello
    I have a problem to make this work:

    SELECT *.
    OF tablename_YY_MM

    (This is part of the script I use YY and MM in different tables)
    I need to find a way for the script asks me every time on AA and the MM
    For example, the current name of the table "tablename_09_08" next month, it will be 'tablename_09_09 '.
    It seems simple, but I can't get it to work. There seems to be a problem with concatenate | and the underscore _
    Looks like this should be done with PL/SQL?

    If anyone can help it will be much appreciated.
    Thank you.

    Published by: user1067236 on August 11, 2009 02:21

    Published by: user1067236 on August 11, 2009 02:23
    SQL>SELECT * FROM tablename_&YY._&MM;
    Enter value for yy: 09
    Enter value for mm: 08
    old   1: SELECT * FROM tablename_&YY._&MM
    new   1: SELECT * FROM tablename_09_08
    SELECT * FROM tablename_09_08
    

    HTH, Urs

  • ADF interview panel with tree Table - add fields

    I created ADF query Panel with tree Table using JDeveloper 11 G. Under the terms of the research advance, add fields only drop-down list the fields in the primary table. My questions are,

    (1) can I search fields in the secondary table? If so, how can I do it?

    (2) how can I customize this drop-down list? Currently it shows just the whole view of the main table with unnecessary data type id.

    Thanks in advance.

    Published by: type on November 9, 2009 09:21

    Hi, I've just uploaded a few screenshots here: http://blog.jangvijay.org/2009/11/step-1-expose-accessor-to-child-vo-in.html
    Sorry if you found my previous answer not clear... :)

  • Is it possible to fill a table with the result of the active query?

    I try to get the content of the cursor c in the ap variable and the code I use is as follows:

    BEGIN
    DECLARE
    TYPE cur_typ IS REF CURSOR;
    c cur_typ;
    query_str VARCHAR2 (1000);
    work VARCHAR2 (1000);
    AP varchar2 (30000);
    to the varchar2 (30000);
    query varchar2 (30000);
    BEGIN
    query_str: = ' select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
    query: = 'CURSOR c IS' |' select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
    IMMEDIATE EXECUTION of the query;

    C OPEN FOR query_str;
    for ap loop query_str
    LOOP
    Fetch c ap;
    EXIT WHEN c % NOTFOUND;
    DBMS_OUTPUT. Put_line(àles);
    END LOOP;
    C CLOSE;
    END;
    END;

    I'll show you a basic approach to the dynamic approach refcursor. But you have to do a lot of work in order to customize it to your needs.

    Here is a demonstration of basic->

    satyaki>
    satyaki>select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    
    Elapsed: 00:00:00.22
    satyaki>
    satyaki>
    satyaki>DECLARE
      2     str         VARCHAR2 (30000);
      3
      4     cursor c1
      5     is
      6       select column_name
      7       from all_tab_columns
      8       where table_name = upper('&tab_nm')
      9       and   column_name = 'ENAME';
     10
     11     r1 c1%rowtype;
     12  BEGIN
     13     str := ' declare '||
     14            '   TYPE cur_typ IS ref cursor; '||
     15            '   c           cur_typ; '||
     16            '   query_str   VARCHAR2 (1000); '||
     17            '   gen_rec '||upper('&tab_nam')||'%rowtype; '||
     18            ' begin '||
     19            '  query_str := '||chr(39)||'select * from emp where rownum < 10'||chr(39)||'; '||
     20            '  OPEN c FOR query_str; '||
     21            '  LOOP '||
     22            '    FETCH c INTO gen_rec; '||
     23            '     EXIT WHEN c%NOTFOUND; ';
     24            for r1 in c1
     25            loop
     26      str := str||'   DBMS_OUTPUT.put_line (gen_rec.'||r1.column_name||'); ';
     27            end loop;
     28      str := str||'  END LOOP; '||
     29            '  CLOSE c; '||
     30            ' end; ';
     31
     32     execute immediate(str);
     33     --dbms_output.put_line(str);
     34  END;
     35  /
    Enter value for tab_nm: emp
    old   8:      where table_name = upper('&tab_nm')
    new   8:      where table_name = upper('emp')
    Enter value for tab_nam: emp
    old  17:           '   gen_rec '||upper('&tab_nam')||'%rowtype; '||
    new  17:           '   gen_rec '||upper('emp')||'%rowtype; '||
    SATYAKI
    SOURAV
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.16
    

    Hope this will give you a basic idea.

    Kind regards.

    LOULOU.

  • Two criteria in mind: one for af:query, second with bind var, both use same result table

    JDeveloper 12.1.2

    I have two display criteria, VC1 and VC2 are based both on the same VO. For example, let's say that I have used VO

    SELECT Employees.EMPLOYEE, Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.DEPARTMENT_ID

    Employees;

    Let this be VC1:

    SELECT * from (SELECT Employees.EMPLOYEE, Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.DEPARTMENT_ID

    EMPLOYEES employees ) QRSLT WHERE 1 = 2


    Used for af:query


    So let's say I have VC2 with bind variable


    SELECT * from (SELECT Employees.EMPLOYEE, Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.DEPARTMENT_ID

    EMPLOYEES employees ) QRSLT WHERE 1 = 2 AND ((UPPER (QRSLT. Department_id) = UPPER(:DeptIdBind))) )

    The user runs the af:query research and resulting table lists some employees. The last value of the column in the table of results, I did as links:

    < af:column headerText = 'Department' id = "c1" width = "140" >

    < af:link shortDesc = "#{bindings.myVO.hints.DepartmentId.tooltip}" id = "ot4" text = ' #{row. "" DepartmentId}'

    action = "#{backingBeanScope.MyBean.byDept}" partialTriggers =": t1" / >

    < / af:column >

    If the user now clicks on the link, I would expect the following:

    1. the values entered in the af: query to stay

    2. the table refreshes since the underlying VC2 is defined and executed VO. Here is the code VOImpl and backingbean

    The bean of support code

    public String byDept() {}

    Links DCBindingContainer = (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();

    DCIteratorBinding dcItteratorBindings = bindings.findIteratorBinding("EmployeesIterator");

    Line r = dcItteratorBindings.getCurrentRow ();

    Object keyvar = r.getAttribute ("DepartmentId");

    OperationBinding searchExp = ADFUtils.findOperation ("searchByDept");

    searchExp.getParamsMap () .put ("deptId", keyvar);

    searchExp.execute ();

    Returns a null value.

    }

    Impl VO

    {} public void searchByDepartment (String deptId)

    setDeptIdBind (deptId);

    executeQuery();

    }

    Problem:

    Query (VC2) runs but table does not reflect that. That is to say I don't see the list of employees of the selected Department

    Any idea?

    RPP = partial page request

    PPR refresh a component jsf

    AdfFacesContext.getCurrentInstance () .addPartialTarget (UIComponent);

    Where component is the component that you want to refresh.

    Have you checked that the query executed vc ID?

    Timo

  • Select a table returned in the result of the query

    Hi, I'm trying to find a way to query a table name that I'm back to a different query. I am doing this in pure SQL and PL/SQL, if I can.

    Here's the situation. I have a table called FILES, a table called TYPE and an unknown number of different reference tables with different names.

    Each entry in the FILE has a reference to a TYPE id, and each entry type is a varchar that contains the name of a table reference, such as PHOTO_INFORMATION, PDF_INFORMATION or XML_INFORMATION.

    I want to be able to extract the data from the reference table for any data file. So with a file id, I question TYPE to get the name of the reference table (IE, "PHOTO_INFORMATION" back) then the request it is at this table for all of its columns, using the reference id in the FILE table.

    The thing is that I wish it were generic, so that I can just add an entry to AA_TYPE and a new table for this type, and then I can ask her but I want, through the FILE table. The reason is that there are some data that is common for all files, and I would like to that data in one place.

    Here is my paintings, I have two reference tables of the sample to the bottom "AA_FILETYPE1" and "AA_FILETYPE_PHOTO".
    CREATE TABLE  "AA_FILES" 
       (     "FILE_ID" NUMBER, 
         "FILE_NAME" VARCHAR2(4000), 
         "FILE_TYPE" NUMBER, 
         "REFERENCE_ID" NUMBER, 
          CONSTRAINT "AA_TEST_FILE_PK" PRIMARY KEY ("FILE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_TYPE" 
       (     "TYPE_ID" NUMBER NOT NULL ENABLE, 
         "REFERENCE_TABLE" VARCHAR2(4000), 
          CONSTRAINT "AA_TYPE_PK" PRIMARY KEY ("TYPE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_FILETYPE1" 
       (     "REFERENCE_ID" NUMBER, 
         "DATE_MODIFIED" DATE, 
         "SUMMARY" VARCHAR2(4000), 
         "TOTAL_VALUE" NUMBER(5,2), 
          CONSTRAINT "AA_FILETYPE1_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_FILETYPE_PHOTO" 
       (     "REFERENCE_ID" NUMBER NOT NULL ENABLE, 
         "DATE_TAKEN" DATE, 
         "CAMERA_NUMBER" VARCHAR2(4000), 
         "WEATHER_CONDITIONS" VARCHAR2(4000), 
         "CONSULTANT_NAME" VARCHAR2(4000), 
          CONSTRAINT "AA_FILETYPE_PHOTO_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE
       )
    /
    Here's an example query I would use:
    select * from (select REFERENCE_TABLE from AA_TYPE where TYPE_ID = AA_FILES.FILE_TYPE) where REFERENCE_ID = AA_FILES.REFERENCE_ID;
    So who withdrew all the columns in the reference given in AA_TYPE table based on an entry in AA_FILES.

    I'm not entirely sure how to do this, or if this is possible even without using PL/SQL.

    I'm open to suggestions on how to achieve what I want with a different design of table, I am a student and I'm not really experienced in database design. (My first design of database class isn't until next year!)

    Thank you very much!

    Hello

    [email protected] wrote:
    Sorry about the confusion about file_id = 3, I meant the insert in the third I've included. I did not indicate the id_fichier in my inserts since it is the main key and it auto increments.

    It is important to post of the CREATE TABLE and INSERT statements that work. All those who want to help you to will want to recreate the problem and test solutions. Also, do not use strings for all entries. If the column is a NUMBER, use a NUMBER in the INSERT statement. If the column is a DATE, use a DATE or a function that returns a DATE.
    So you should post something like:

    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (1, 'test-photo-1.jpg',  1,  1);
    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (2, 'test-xml-1.jpg',    2,  2);
    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (3, 'test-photo-2.jpg',  1,  2);
    -- The value file_type=1 immediately above was not in your original data, but seems to be what you meant.
    
    prompt =====  AA_TYPE Table:  =====
    
    insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (1, 'AA_FILETYPE_PHOTO');
    insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (2, 'AA_FILETYPE1');
    
    prompt =====  AA_FILETYPE1 Table:  =====
    
    insert into AA_FILETYPE1 (REFERENCE_ID, DATE_MODIFIED,                 SUMMARY,                                    TOTAL_VALUE)
           values           (1,           TO_DATE ('01-01-02', 'MM-DD-RR'), 'An XML file that has some information about something', '14');
    
    prompt =====  AA_FILETYPE_PHOTO Table:  =====
    
    insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN,                 CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME)
                    values            (1,          TO_DATE ('01-01-01', 'MM-DD/RR'), 'abc123',      'rainy!',         'John Smith');
    insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN,                 CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME)
                    values            (2,          TO_DATE ('01-01-02', 'MM-DD/RR'), 'def456',      'slightly cloudy',  'Jane Jones');
    commit;
    

    To give you my workplace, I'm applying in Application Express. A user has entered the number '3' the file_id (I'm not worried about the distinction between passing in the id_fichier and the name of the file, I just my application one application or the other).

    Now, run a query that will get related data which table it is stored in. I don't know the name of the table at design time, as that particular file may be of any type (each of which has a different table name). However, with a the file_id, I have a file_type (in aa_files) which refers to an entry in aa_type.

    I see. You could add even add new tables after this query is written. As long as the new table has a column named reference_id, and there is a line for the new table in aa_files, the following query should work.

    >

    select FILE_TYPE
    from AA_FILES
    where FILE_ID = 3
    

    I stored the name of the table, I need to ask for the rest of the data in aa_type at design time, so using the file_type value, I can get the name of reference_table:

    select REFERENCE_TABLE from AA_TYPE where FILE_TYPE = 1
    

    In the sample data, you have validated, Type_de_fichier = 2 on the 3rd row. I've changed that in my example 1 revised data.
    Be very careful that your explanation fits your data. You talk to people who know about your application, and it is very easy for them to be induced in error or confusion.

    Now the '1' is here that the first query would return. I would like to use a subquery to combine these two queries into a single (I think?). This second query would return "AA_FILETYPE_PHOTO", which is the reference table.

    So I have the reference table, which is a name of table to another table in my database. It contains the data that I'm actually looking for. I want it for this particular file (file_id 3), and in aa_files, I have a value of "reference_id", which refers to the respective line in the reference table. File_id 3, the reference_id is 2.

    select * from AA_FILETYPE_PHOTO
    where reference_id = 2
    

    If the above query gets me my final data.

    Now, I've been watching substitution values and bind variables, here's another way to explain what I want:

    Explanation step by step below is very useful. It would be more useful if each step uniquely and gavce movement results given the sample data and an example of setting (3 in this case)

    -- get the file_type from aa_files for the desired file
    EXEC :file_type := (select file_type from aa_files where file_id = 3);
    

    That we will call the step step (a) above.
    Step (a) sets: Type_de_fichier 1 (given my corrected sample data)

    -- get the reference table from aa_types using the file_type
    EXEC :reference_table := (select reference_table from aa_type where type_id = :file_type);
    

    That we will call the step step (b) above.
    (B) sets the stage: reference_table to 'AA_FILETYPE_PHOTO '.

    -- get the reference_id from aa_files for the desired file
    EXEC :reference_id := (select reference_id from aa_files where file_id = 3);
    

    That we will call the step step (c) above.
    (C) sets the stage: reference_id 2

    -- using the reference table and reference id for the desired file, get the rest of the data
    select * from :reference_table where reference_id = :reference_id;
    

    Not sure if this makes it more clear or not.

    Yes, it helps a lot.

    Basically I have a table full of table names. How do I write a query that pulls one of these table names and it then queries?

    You need SQL dynamic, because you can't hardcode a table name in the query that you normally would be.
    How dynamic SQL works normally (and the functioning of this example) are that the query is built by using a variable. In SQL * more (as shown below), you can simply use a variable substitution instead an identifier hardcoded, and that's what it takes to make the dynamic query from SQL * more resolves the substitution variables before sending the code for the compiler. I don't know much on the Apex, but I bet there's some way to do dynamic SQL in the Apex, too.
    So the dynamic part here should include step d, since you can't hardcode the name of the table in the query.
    Until we can step (d), then, did they to us to do the steps (a) and (b) to obtain this file name. In the example blelow, I used a separate, preliminary request to get the & table_name...
    Step (c) could be made in the main query, using a subquery or a join. However, I chose to step (c) in the preliminary motion, as well as steps (a) and (b), since it's the same table same step (a). In this way, step (d) must refer to a table.

    Here's (finally) how to make this work in SQL * more:

    ACCEPT     file_id     PROMPT     "Enter the file_id (a number, e.g. 3): "
    
    -- Preliminary Query, to set table_name
    
    COLUMN     reference_id_col     NEW_VALUE     reference_id
    COLUMN     table_name_col           NEW_VALUE     table_name
    
    SELECT  f.reference_id          AS reference_id_col
    ,     t.reference_table       AS table_name_col
    FROM      aa_files     f
    JOIN     aa_type          t     ON     f.file_type     = t.type_id
    WHERE     f.file_id     = &file_id
    ;
    
    --     Main Query
    
    SELECT  *
    FROM     &table_name
    WHERE      reference_id     = &reference_id
    ;
    

    The results, account required to the data from the sample I posted above, and the & file_id 3, are:

    `                      CAMERA_    WEATHER_        CONSULTANT_
    REFERENCE_ID DATE_TAKE NUMBER     CONDITIONS      NAME
    ------------ --------- ---------- --------------- ---------------
               2 01-JAN-02 def456     slightly cloudy Jane Jones
    

Maybe you are looking for