No join in the query involving 2 tables

Friends,
I saw a strange plan for one query in TESTING DB today. Although 2 tables are involved i dont see any join , NL/HJ/SMJ !!
Can you please tell why this might be happening?
Note: i am not facing any performance issue but curious to know what type of optimization oracle is doing here.
It would be great if you could direct me the relevant link in the documentation.
Query text and plan :
SELECT FIRST_NAME
  FROM CAMPA.TABLE_A
WHERE NAME_ID =
          (SELECT NAME_ID
             FROM CAMPA.TABLE_B
            WHERE ban=:b1);
Plan hash value: 311916800
| Id  | Operation                             | Name                  | Rows  | Bytes | Cost  | Pstart| Pstop |
|   0 | SELECT STATEMENT                      |                       |     1 |    12 |     2 |       |       |
|   1 |  PARTITION RANGE SINGLE               |                       |     1 |    12 |     1 |   KEY |   KEY |
|   2 |   TABLE ACCESS BY LOCAL INDEX ROWID   | TABLE_A               |     1 |    12 |     1 |   KEY |   KEY |
|*  3 |    INDEX UNIQUE SCAN                  | TABLE_A_PK            |     1 |       |     1 |   KEY |   KEY |
|   4 |     PARTITION RANGE SINGLE            |                       |     2 |    30 |     1 |   KEY |   KEY |
|   5 |      TABLE ACCESS BY LOCAL INDEX ROWID| TABLE_B               |     2 |    30 |     1 |   KEY |   KEY |
|*  6 |       INDEX RANGE SCAN                | TABLE_B_2IX           |     2 |       |     1 |   KEY |   KEY |
Predicate Information (identified by operation id):
   3 - access("NAME_ID"= (SELECT "NAME_ID" FROM "CAMPA"."TABLE_B" "TABLE_B"
              WHERE "BAN"=TO_NUMBER(:B1)))
   6 - access("BAN"=TO_NUMBER(:B1))
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE    11.1.0.7.0      Production
TNS for HPUX: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production

With equality condition can i get NL/HJ join where the outer row source comes from the subquery?
What condition/pre-requisite of NL/HJ join is not met in this case?Don't use an equality condition with a subquery - this implicitly makes available to the CBO an optimisation strategy that can only be used if the subquery is guaranteed to return a single row.
So either use IN rather than = or use a JOIN not a SUBQUERY.
It's a bit of a strange question.
How do I remove this optimisation?
Take away the features that make that optimisation a possibility.
Edited by: Dom Brooks on May 13, 2013 2:20 PM

Similar Messages

  • The Connection String for the Query Log table is automatically encrypted.

    When I try to use the Usage Based Optimization to apply Aggregation Design to my measure group, it shows me the following
    error message.
    The connection string cannot be found. Open Microsoft SQL Server Management Studio and, in the Analysis Server Properties
    page, check the value of the Log\QueryLog\QueryLogConnectionString
    property.
    I encountered this error like two weeks ago.  At that time I just reset the connection string and every things seem
    to be fine.  A week ago, I successfully applied the Usage Based Optimization for one of my cubes.  However when I tried to apply UBO for my other cubes today, I encountered the same issue again!  I believe no one has changed the property of
    the connection string.
    Also if I query the Query Log table, I can see those latest queries made by the users.  I'm sure the queries are still
    logging into this table.
    This is really strange.  Anyone else has encountered the same issue?  Thanks.

    Hello Thomas,
    I encounterd this issue. And I am struggling trying to solve this problem. If you have resolved this issue and I guess you must've, because this post is two years old, could you kindly post how you resolved this issue?
    Thanks in advance
    Best Regards,
    Neeraja

  • Simultaneous hash joins of the same large table with many small ones?

    Hello
    I've got a typical data warehousing scenario where a HUGE_FACT table is to be joined with numerous very small lookup/dimension tables for data enrichment. Joins with these small lookup tables are mutually independent, which means that the result of any of these joins is not needed to perform another join.
    So this is a typical scenario for a hash join: the lookup table is converted into a hashed map in RAM memory, fits there without drama cause it's small and a single pass over the HUGE_FACT suffices to get the results.
    Problem is, so far as I can see it in the query plan, these hash joins are not executed simultaneously but one after another, which renders Oracle to do the full scan of the HUGE_FACT (or any intermediary enriched form of it) as many times as there are joins.
    Questions:
    - is my interpretation correct that the mentioned joins are sequential, not simultaneous?
    - if this is the case, is there any possibility to force Oracle to perform these joins simultaneously (building more than one hashed map in memory and doing the single pass over the HUGE_FACT while looking up in all of these hashed maps for matches)? If so, how to do it?
    Please note that the parallel execution of a single join at a time is not the matter of the question.
    Database version is 10.2.
    Thank you very much in advance for any response.

    user13176880 wrote:
    Questions:
    - is my interpretation correct that the mentioned joins are sequential, not simultaneous?Correct. But why do you think this is an issue? Because of this:
    which renders Oracle to do the full scan of the HUGE_FACT (or any intermediary enriched form of it) as many times as there are joins.That is (should not be) true. Oracle does one pass of the big table, and then sequentually joins to each of the hashmaps (of each of the smaller tables).
    If you show us the execution plan, we can be sure of this.
    - if this is the case, is there any possibility to force Oracle to perform these joins simultaneously (building more than one hashed map in memory and doing the single pass over the HUGE_FACT while looking up in all of these hashed maps for matches)? If so, how to do it?Yes there is. But again you should not need to resort to such a solution. What you can do is use subquery factoring (WITH clause) in conjunction with the MATERIALIZE hint to first construct the cartesian join of all of the smaller (dimension) tables. And then join the big table to that.

  • Outer Join with the query

    I have written the below query, our requirement is, Some employees have "Transport Allowance" but not "Project Allowance". For this, I tried to use OUTER JOIN with this query. But this query takes long time and failed. The following query works fine if the employee has both "Transport Allowance" and "Project Allowance" (without outer join) Now, I also need to retrieve the employees who have "Transport Allowance" but not "Project Allowance". How can I retrieve it?
    SELECT DISTINCT papf.employee_number
    , peev.screen_entry_value Transport_Allowance
    ,peev1.screen_entry_value Project_Allowance
    FROM apps.per_all_people_f papf
    ,apps.per_all_assignments_f paaf
    ,apps.pay_element_types_x petf
    ,apps.pay_element_types_x petf1
    ,apps.pay_element_types_x petf2
    ,apps.pay_element_entries_f peef
    ,apps.pay_element_entries_f peef1
    ,apps.pay_element_entries_f peef2
    ,apps.pay_element_entry_values_x peev
    ,apps.pay_element_entry_values_x peev1
    ,apps.pay_element_entry_values_x peev2
    ,apps.pay_input_values_x pivf
    ,apps.pay_input_values_x pivf1
    ,apps.pay_input_values_x pivf2
    WHERE
    papf.person_id = paaf.person_id
    AND paaf.assignment_id = peef.assignment_id
    AND paaf.assignment_id = peef1.assignment_id
    AND paaf.business_group_id = papf.business_group_id
    --Transport Allowance
    AND peef.element_entry_id = peev.element_entry_id
    AND petf.element_Name = 'Transport Allowance'
    AND pivf.element_type_id =petf.element_type_id
    AND pivf.name = 'Allowance'
    AND peev.input_value_id= pivf.input_value_id
    --Project Allowance
    AND peef1.element_entry_id = peev1.element_entry_id
    AND petf1.element_Name = "Project Allowance'
    AND pivf1.element_type_id = petf1.element_type_id
    AND pivf1.name = 'Allowance'
    AND peev1.input_value_id = pivf1.input_value_id
    AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
    AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
    AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
    ORDER BY papf.employee_number
    Thanks in advance.

    I am using sames tables with alias to retrieve the columns values from the same table.
    Here is my query.
    SELECT DISTINCT papf.employee_number
    , peev.screen_entry_value Transport_Allowance
    ,peev1.screen_entry_value Project_Allowance
    FROM apps.per_all_people_f papf
    ,apps.per_all_assignments_f paaf
    ,apps.pay_element_types_x petf
    ,apps.pay_element_types_x petf1
    ,apps.pay_element_entries_f peef
    ,apps.pay_element_entries_f peef1
    ,apps.pay_element_entry_values_x peev
    ,apps.pay_element_entry_values_x peev1
    ,apps.pay_input_values_x pivf
    ,apps.pay_input_values_x pivf1
    WHERE
    papf.person_id = paaf.person_id
    AND paaf.assignment_id = peef.assignment_id
    AND paaf.assignment_id = peef1.assignment_id
    AND paaf.business_group_id = papf.business_group_id
    --Transport Allowance
    AND peef.element_entry_id = peev.element_entry_id
    AND petf.element_Name = 'Transport Allowance'
    AND pivf.element_type_id =petf.element_type_id
    AND pivf.name = 'Allowance'
    AND peev.input_value_id= pivf.input_value_id
    --Project Allowance
    AND peef1.element_entry_id = peev1.element_entry_id
    AND petf1.element_Name = "Project Allowance'
    AND pivf1.element_type_id = petf1.element_type_id
    AND pivf1.name = 'Allowance'
    AND peev1.input_value_id = pivf1.input_value_id
    AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
    AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
    AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
    ORDER BY papf.employee_number
    Thanks in advance.

  • Remove Power Query queries while keeping the query output tables

    I use power query to load data from external sources into several excel tables. Before sending this excel to a client, I would like to remove all power query queries (M code) while keeping the output/query tables at place.
    My current workaround is:
    unload Power Query
    convert each table to range
    load Power Query
    delete queries (M code)
    Is there a better/faster way to achieve what I want?

    You can unlink the existing tables and remove custom XML data in Document Inspector. No need to duplicate the worksheet.
    exactly. and even unlinking the tables is not neccessary for DocInspector to remove the custom XML of PQ.
    Do you have any suggestion on how to trigger the cleaning of PQ XML code via VBA? 
    the following code does not work:
    ActiveWorkbook.RemoveDocumentInformation (xlRDIAll)

  • How to build dynamic query strings in the query using DB adapter 'Pure SQL'

    Dear Forum,
    I am building an application which will access DB to fetch some result set. The query involves retrieving data from multiple tables(nearly 10 tables). So I have created a DB adapter using 'execute pure sql' option. With this query works fine, but my inputs parameters will vary. So I need to make my query dynamic to append the query strings at runtime depending on the inputs.
    For example I have 3 input variables - input1,input2 and input3 (in my request xsd) which are used in the pure sql query. Now if I get a 4th input parameter input4 in the request, I need to append this to query string as 'AND input4=[some value]' at runtime. Otherwise my query should have only 3 parameters. Please suggest how this can be achieved.
    Regards,
    Satya.

    This is a strange requirement, depending on the columns you have and what are optional in them, one way is to have separate operations and each opeartion will have different inputs and for each operation , a different DB Adapter is called. But this way, it results in more number of operations for the service as well as more number of references in the composite. Even if you pass the column inputs to the SQL procedure, it will result in a large number of if-else cases..
    Thanks,
    N

  • Defaulting Null Values in an outer join to the last joined row's values.

    I have a situation where I need to fill in the missing values from an outer join with the last values returned by the join.
    The query is based on a date table, an organization table and a transaction table.
    SELECT D.DATE_ID, O.ORG_ID, T.VALUE
    FROM D_ORGANIZATION O, D_DATE D, F_TRANSACTION T
    WHERE D.DATE_ID = T.DATE_ID(+)
    AND T.ORG_ID = O.ORG_ID(+)
    AND O.ORG_NAME = '&NAME'[
    AND D.THE_DATE >= ADD_MONTHS( TO_DATE( '&&PERIOD_DATE', 'DD-MON-YYYY' ), -23 )
    AND D.THE_DATE <= ADD_MONTHS( TO_DATE( '&&PERIOD_DATE', 'DD-MON-YYYY' ), 24 )
    So the query will return all dates in the 4 year period, and where transactions exist the relevent value.
    DATE_ID ORG_ID VALUE
    38291     2 99.8
    38321     2 45.1
    38352     
    38383     
    38411     
    What I need to happen is:
    DATE_ID ORG_ID VALUE
    38291     2 99.8
    38321     2 45.1
    38352     2 45.1     
    38383 2 45.1
    38411     2 45.1
    Lag appears to be of no use because it will only pick up the last genuine value, so using
    NVL(T.VALUE, LAG(T.VALUE,1) OVER ( .... )
    Gives:
    ATE_ID ORG_ID VALUE
    38291     2 99.8
    38321     2 45.1
    38352     2 45.1     
    38383
    38411     
    The length of the data gap can vary as constituent organisations don't all return their data at the same time, and there may be intermediate dates where no data is returned , but the value needs to be calculated.
    What's going on here is that a gaph is being generated where the tool requires data points to plot the line, once the real data ends a bespoke trend calculations takes over based on the last value returned. I do not have access to the data warehousing options so a solution that doen't need them would be handy, but if not then options can be purchased.
    The tool can't use PL/SQL, but is perhaps a bespoke function in order?

    To do this wouldn't you need to know the data in advance? The real source table had 1800 organisations and 8,000,000 transactions.
    I Tried this as well, creating a pl/sql package as follows.
    create or replace PACKAGE stack AS
    TYPE gnt_push_numbers IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
    TYPE gvt_push_varchars IS TABLE OF VARCHAR(1000) INDEX BY PLS_INTEGER;
    gna_push_numbers gnt_push_numbers;
    gva_push_varchars gvt_push_varchars;
    FUNCTION PUSH ( pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
    FUNCTION PUSH ( pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
    FUNCTION POP_NUM ( pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
    FUNCTION POP_VAR ( pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
    END stack;
    CREATE OR REPLACE
    PACKAGE BODY "STACK" AS
    FUNCTION push(pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER deterministic IS
    BEGIN
    gna_push_numbers(pn_offset) := pn_push_var;
    RETURN pn_push_var;
    END push;
    FUNCTION push(pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR deterministic IS
    BEGIN
    gva_push_varchars(pn_offset) := pv_push_var;
    RETURN pv_push_var;
    END push;
    FUNCTION pop_num(pn_offset NUMBER) RETURN NUMBER deterministic IS
    BEGIN
    RETURN gna_push_numbers(pn_offset);
    END pop_num;
    FUNCTION pop_var(pn_offset NUMBER) RETURN VARCHAR deterministic IS
    BEGIN
    RETURN gva_push_varchars(pn_offset);
    END pop_var;
    END stack;
    Unfortunately it appears to act before the rows are sorted, so will only work in specialised circumstances, in that you have to ensure the rows have been sorted before the function is used.
    SELECT PUSH(COL), POP..(COL)
    FROM ( SELECT etc.
    Luckily the client decided they didn't want to mix their graphs any more so a more classic approach using a base table select for actuals and then a date table select with a sub-query columns for the projection provided a simple solution.

  • SQL statement that includes LEFT & RIGHT JOIN in the same statement??? Help

    Hi,
    How an I write an SQL statement with a GROUP BY that will both (a) include the NULL value from the left hand table, but also (b) include ALL columns from the right hand table. It's like I need a LEFT JOIN and a RIGHT JOIN in the query at the same time.
    Here's an example of the 2 tables I have and the result I'm after. As you can see I want the NULL's from Expenses Table summed, as well as include all categories from the right hand table (i.e. even if there are no expenses against them)
    Table = Expenses
    Amount Category
    $10 1
    $20 2
    $30 1
    $40 NULL {i.e. not yet categorised}
    Table = Categories
    ID Title
    1 Food
    2 Entertainment
    3 Travel
    4 Personal
    REQUIRED RESULT
    Category Total
    Food 40
    Entertainment 20
    Travel 0
    Personal 0
    NULL 40
    Thanks

    SQL> create table expenses (amount,category)
      2  as
      3  select 10, 1 from dual union all
      4  select 20, 2 from dual union all
      5  select 30, 1 from dual union all
      6  select 40, null from dual
      7  /
    Table created.
    SQL> create table categories (id,title)
      2  as
      3  select 1, 'Food' from dual union all
      4  select 2, 'Entertainment' from dual union all
      5  select 3, 'Travel' from dual union all
      6  select 4, 'Personal' from dual
      7  /
    Table created.
    SQL> select c.title category
      2       , nvl(sum(e.amount),0) total
      3    from expenses e
      4         full outer join categories c on (e.category = c.id)
      5   group by c.id
      6       , c.title
      7   order by c.id
      8  /
    CATEGORY                                       TOTAL
    Food                                              40
    Entertainment                                     20
    Travel                                             0
    Personal                                           0
                                                      40
    5 rows selected.Regards,
    Rob.

  • Optimizing the Query.

    Hello All,
    I need to uptimize the below query. I am using oralce 9i and rule base optimisation.
    "SELECT sp.store_cd wr_store_cd, l.store_cd, l.loc_cd, l.loc_tp_cd,
    sp.pd_cd, MIN(sp.priority), MIN(sp.ck_showroom)
    FROM store$pri sp, loc l
    WHERE l.store_cd >= nvl(sp.beg_store_cd,' ')
         AND l.store_cd <= nvl(sp.end_store_cd,' ')
    AND l.loc_cd >= nvl(sp.beg_loc_cd,' ')
         AND l.loc_cd <= nvl(sp.end_loc_cd,' ')
    AND l.pick = 'Y'
    GROUP BY sp.store_cd, sp.pd_cd, l.store_cd, l.loc_cd, l.loc_tp_cd
    ORDER BY wr_store_cd, pd_cd, MIN(priority), l.store_cd;"
    In the above query LOC table has the less data and STORE$PRI table has the more data. Also in the LOC table there is a Index (Composit) with LOC_cd and STORE_CD column. In the STORE$PRI table there are no index in the beg_store_cd, end_store_cd, beg_loc_cd and end_loc_cd column. Also if I am creating the index on it as I am using the NVL function it is not doing the index scan.
    Any suggestion how to optimize this query. It is taking 250 minute for getting the 396750 records. In LOC table there are 28859 records and in STORE$PRI table there are 465 redords.
    I am putting below the explan plan data.
    <pre>
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=RULE                                        
    SORT ORDER BY                                        
    SORT GROUP BY                                        
    TABLE ACCESS BY INDEX ROWID     INV.LOC                                   
    NESTED LOOPS                                        
    TABLE ACCESS FULL     SALES.STORE$PRI                                   
    INDEX RANGE SCAN     INV.LOC_PK          
    </pre>
    Trce File Data:-
    <pre>
    recursive calls     793
    db block gets     113
    consistent gets     32377
    physical reads     211
    redo size     15044
    bytes sent via SQL*Net to client     1431124
    bytes received via SQL*Net from client     49632
    SQL*Net roundtrips to/from client     1357
    sorts (memory)     4
    sorts (disk)     0
    </pre>
    Regards
    SUN
    Edited by: User SUN@ on Sep 17, 2008 6:51 PM
    Edited by: User SUN@ on Sep 17, 2008 9:09 PM

    could you please tell me how to use has join in the query?Hash joins are not a feature of the rule based optimizer. Normally you would keep your stats up to date and the cost-based optimizer will choose a hash join automatically where appropriate. Why are you using RBO?

  • Improve the query performance

    Hi, I need help for improving query performance..
    I have a query in which i am joining 2 tables, join after some aggregation. Both table has more than 50 million record. 
    There is no index created on these table,both tables are loaded after truncation. So is it required to create index on this table before joining? The query status was showing 'suspended' since it was running for long time. For temporary purpose, i just executed
    the query multiple times by changing month filter each times. 
    How can i improve this instead of adding month filter and running multiple times

    Hi Nikkred,
    According to your description, you are joining 2 table which contain more than 50 million records. Now what you want is improving query performance, right?
    Query tuning is not an easy task. Basically it depends on three factors: your degree of knowledge, the query itself and the amount of optimization required. So in your scenario, you can post your detail query, so that you can get more help. Besides, you
    can create index on your table which can improve the performance. Here are some links about performance tuning tips for you reference.
    http://www.mssqltips.com/sql-server-tip-category/9/performance-tuning/
    http://www.infoworld.com/d/data-management/7-performance-tips-faster-sql-queries-262
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to implement 'Quick Select' column in a query result table?

    Hi,
    I have a requirement in OAF to design a search page with 'Quick select' column.
    One of the column in the query result table should be a quick select.
    Once user clicks on the quick select column, we have to navigate back to the previous page with the row value selected.
    Can anyone help me in this.
    Thanks.

    Also refer the search exercise in the toolbox tutorials.
    you can implement the quick search in the same way as update and delete buttons.
    --Prasanna                                                                                                                                                                                                                                                                                                                                   

  • Optimizing the Query  joining two tables multiple times

    Hi all,
    I need to formulate a query where I want to get data from two tables.Here are the table structures and sample data.
    Table1
    id firstname lastname accountnumber
    1 Sridh Peter SP456
    2 Gane San SS667
    3 Sway patel PP345
    Table 2
    id attributename attributevalue
    1 Manager Mike
    1 Lawyer Schwa
    1 Server maneka
    1 location langur
    1 System Novel
    2 Manager kane
    2 lawyer endun
    2 location colrado
    3 server queen
    3 system elanda
    The requirement is I need to generate a report like th follwoing
    Accountnumber firstname lastname manager lawyer System Server location
    SP456 Sridh Peter Mike schwa Novel maneka langur
    SS667 Gane San kane endun colrado
    Now I have done this report using a query where I join table1 and table2 multiple times to get the report's data. And that query only works If the user has all attributes.If any one attribut is missing it wont work.Can some onehelp me with this.
    The query i am using looks like this.
    select a.accountnumber,a.firstname,a.lastname,b.attributevalue,c.attributevalue, d.attributevalue, e.attributevalue,f.attributevalue from table1 a,table2 b where a.id=b.id and a.id=c.id and a.id=d.id and a.id=e.id and a.id=f.id and b.attributename ='manager' and c.attributename ='lawyer' and d.attributename='system' and e.attributename='server' and f.attributename='location'
    this query works well if a user has all attributes ,if any one is missing he is not shown in the report.Can some one suggest me a good way of querying than this.
    The query I am using is also taking lot of time..I think I have explained my question well ,please reply if you have questions.
    Thanks for reading till here patiently,
    Pandu

    ....if this .....
    <DIV><B>
    <P><FONT face=Tahoma size=2>select</FONT></B><FONT size=2><FONT face=Tahoma>
    Accountnumber||</FONT><FONT face=Tahoma>' '||firstname||' '||lastname||'
    '||manager||' '||<B>System</B>||' '||Server||' '</FONT></FONT><FONT face=Tahoma
    size=2>||location<BR><B>from<SPAN
    class=940214002-13042006>     </SPAN></B>(<B>select</B>
    * <BR><B><SPAN
    class=940214002-13042006>             
    </SPAN>from<SPAN class=940214002-13042006>  </SPAN></B>(<B>select</B> '1'
    id, 'Sridh' firstname, 'Peter' lastname, 'SP456'</FONT><FONT face=Tahoma size=2>
    accountnumber <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                        
    </SPAN>select</B> '2' id, 'Gane' firstname, 'San' lastname, 'SS667'</FONT><FONT
    face=Tahoma size=2> accountnumber <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                          </SPAN>select</B>
    '3' id, 'Sway' firstname, 'patel' lastname, 'PP345'</FONT><FONT face=Tahoma
    size=2> accountnumber <B>from</B> dual) x,<BR><BR><SPAN
    class=940214002-13042006>           
    </SPAN>(<B>select</B> * <BR><B><SPAN
    class=940214002-13042006>             </SPAN>from</B>
    (<B>select</B> id,<BR><SPAN
    class=940214002-13042006>                                  </SPAN>attributename,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,0</FONT><FONT face=Tahoma size=2>) over (<SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id) <B>as</B> Manager,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,1</FONT><FONT face=Tahoma size=2>) over (<B><SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id</B>) <B>as</B> Lawyer,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,2</FONT><FONT face=Tahoma size=2>) over (<B><SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id</B>) <B>as</B> System,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,3</FONT><FONT face=Tahoma size=2>) over (<B><SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id<SPAN class=940214002-13042006>)</SPAN></B> <B>as</B>
    Server,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,4</FONT><FONT size=2><FONT face=Tahoma>) over
    (<B><SPAN class=940214002-13042006><STRONG>partition by </STRONG>id
    </SPAN><B>order</B> <B>by</B> id</B>) <B>as</B> Location<BR><B><SPAN
    class=940214002-13042006>                     
    </SPAN>from</B> (<B>select</B> *<SPAN class=940214002-13042006>
    </SPAN></FONT></FONT><FONT size=+0><FONT face=Tahoma><FONT size=2><B>from</B>
    (<B>select</B> '1' id, 'Manager' attributename, 'Mike'</FONT></FONT></FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '1' id, 'Lawyer' attributename, 'Schwa'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '1' id, 'Server' attributename, 'maneka'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                      
    </SPAN>select</B> '1' id, 'location' attributename, 'langur'</FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                      
    </SPAN>select</B> '1' id, 'System' attributename, 'Novel'</FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '2' id, 'Manager' attributename, 'kane'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '2' id, 'lawyer' attributename, 'endun'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                      
    </SPAN>select</B> '2' id, 'location' attributename, 'colrado'</FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '3' id, 'server' attributename, 'queen'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '3' id, 'system' attributename, 'elanda'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual)<BR><B><SPAN
    class=940214002-13042006>                                </SPAN>order</B>
    <B>by</B> id, (<B>case</B> <B>when</B> attributename='Manager' <B>then</B>
    1</FONT><FONT face=Tahoma size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='Lawyer' <B>then</B> 2</FONT><FONT face=Tahoma
    size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='System' <B>then</B> 3</FONT><FONT face=Tahoma
    size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='Server' <B>then</B> 4</FONT><FONT face=Tahoma
    size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='Location' <B>then</B> 5</FONT><FONT
    face=Tahoma><FONT size=2> <B>end</B>) <B>asc</B>))<BR><B><SPAN
    class=940214002-13042006>           
    </SPAN>where</B> attributename='Manager'</FONT></FONT><FONT face=Tahoma size=2>)
    y<BR><B>where</B> x.id(+)=y.id)</FONT></P></DIV>
    < Jonel

  • How to tune the query for duplicate records while joining the two tables

    hi,i am executing the query which has retrieving multiple tables,in which one of them has duplicate record,how to get single record

    Not enough info...subject says "tune" the query, message says "write" the query...and where is actual query that you had tried ?

  • Optimizing the query containing 7 table joins

    hi,, I have a query which is taking almost 20 minutes to retrieve the data from DB. let me know how can i further optimize the query.. the tables contains huge amount of data
    Table1 a -> 1040131 rows
    Table2 b -> 1040131 rows
    Table3 c -> 2080262 rows
    Table4 d -> 2749 rows
    Table5 e -> 1040131 rows,
    Table6 f -> 93819 rows
    Table7 g -> 99203 rows
    My query is
    SELECT a.lid, g.image, f.product , d.manufacturer, b.desc, c.price, c.abbr, c.currency, c.class
    FROM
    Table1 a,
    Table2 b,
    Table3 c,
    Table4 d,
    Table5 e,
    Table6 f,
    Table7 g
    WHERE (UPPER(b.desc) like '%TEST%' OR UPPER(b.desc) like '%BEST%')
    and a.line = b.line
    AND a.line = c.line
    AND c.subset = 576
    AND a.manufacturer = d.manufacturer
    AND a.line = e.line
    and a.product = f.product
    and e.image = g.image
    Please tell me how can i optimize this query further to work faster

    user1708333 wrote:
    WHERE (UPPER(b.desc) like '%TEST%' OR UPPER(b.desc) like '%BEST%')
    I would imagine that that line is the main culprit.
    You are doing a free text search which will always result in a full table scan the way you are doing it.
    If you need free text searching then you should consider using [Oracle Text|http://www.oracle.com/technology/products/text/index.html]

  • SQ01 Query issue - Table join

    Hi Gurus,
    I need to make a change in already created query generating a report concerning Billing documents. Tables which are being used in there are VBRK, VBRP, VBPA & KNA1.
    Now, I would like to add Purchase Order number as field in Field Group in related Infoset in SQ02.
    The issue is when I include table VBKD field VBKD-BKSTD  to fetch PO number and join it in infoset, it does get joined but the actual query does not work in SQ00 or SQ01 after getting this change done in infoset.
    Can you please suggest if I am doing something wrong in joining the tables or should I try joining some other table to get this requirement??
    Kindly help and thanks in advance for your suggestions!!
    Regards
    Bawa

    Hi Shiva,
    The issue is that I cannot use the field VBRP-AUBEL as it contains the document number of referenced Sales Document which is sales order type document number in my case.
    Kindly suggest if I am doing something wrong in joining or do I have take care of some steps involving joining of tables??
    Thanks
    Bawa
    Edited by: Bawa Bawa on Sep 23, 2009 9:44 PM
    Edited by: Bawa Bawa on Sep 24, 2009 9:32 AM

Maybe you are looking for

  • PPro engine for video playback question

    Joe mentioned in another thread that Encore 2.0 uses "PPro engine ... for video playback, instead of DirectShow". Does this imply that Encore DVD requires a CPU with the SSE2 instruction set like PPro does? Thanks.

  • LOVs in HtmlDB

    Hi, I am trying to create an LOV which returns multiple values. For example: If I search for a name in the lov and select a particular name, then I want to return the phone number and email address as well as the name to the parent screen. Can somebo

  • Vendormaste creation in new gl

    hi friends Here my question is vendor master creation , before i was configure every thing correct i was checked every thing.while creating vendor master reconsilization not comine (sundry creditor) Moderator: Please, avoid asking basic questions

  • Program units at forms 10g

    Hey friends, I have a lot of user made procedures built in the program units of forms. Since ia m in a process to make a web server of teh forms application, i wanted to know that would these program units cause any performance problems on the applic

  • CS6 programs start telling me I'm using a trial when I'm not

    I have a creative cloud account and use the programs on two computers. Since a week or so one of the computers Adobe keeps reminding me that my trial version will only work for a limited remaining number of days. It gives me the option to keep on usi