Query count help

Dear friends,
Below is my query
Select Count(distinct(decode(d.invtype,1,invno) inv_x,
       Count(distinct(decode(d.invtype,2,d.invno))) inv_y
       from inv_mstr m, inv_dtls d
where m.invno = d.invno(+) and m.inv_date between '01-dec-2012' and '31-dec-2012'
I am counting record base on some conditon. inv_x and inv_y
My request is -  Some times record is not exist in inv_dtls (details table )  In this case I want add this record into inv_x count
Kindly give me a suggestion
Rgds
Rdk

Hi Rdk,
if the invno does not exist in the inv_dtls, the outer join "gives you" all fields from inv_dtls as NULL in the result. Assuming that inv_dtls.invtype cannot be NULL otherwise (e.g. not null constraint on the column), you can use NVL to "simulate" the invtype you want:
Count(distinct(decode(nvl(d.invtype,1),1,invno) inv_x
Otherwise, use the column from the join condition (since d.invno is not = m.invno, it must be NULL as result from the outer join, it cannot be any other value):
Count(distinct(decode(nvl2(d.invno,d.invtype,1),1,invno) inv_x
//Tine

Similar Messages

  • [Mostly Sorted] Extracting tags - regexp_substr and count help needed!

    My original query got sorted, but additional regexp_substr and count help is required further on down!
    Hi,
    I have a table on a 10.2.0.3 database which contains a clob field (sql_stmt), with contents that look something like:
    SELECT <COB_DATE>, col2, .... coln
    FROM   tab1, tab2, ...., tabn
    WHERE tab1.run_id = <RUNID>
    AND    tab2.other_col = '<OTHER TAG>'(That's a highly simplified sql_stmt example, of course - if they were all that small we'd not be needing a clob field!).
    I wanted to extract all the tags from the sql_stmt field for a given row, so I can get my (well not "mine" - I'd never have designed something like this, but hey, it works, sorta, and I'm improving it as and where I can!) pl/sql to replace the tags with the correct values. A tag is anything that's in triangular brackets (eg. <RUNID> from the above example)
    So, I did this:
    SELECT     SUBSTR (sql_stmt,
                       INSTR (sql_stmt, '<', 1, LEVEL),
                       INSTR (substr(sql_stmt, INSTR (sql_stmt, '<', 1, LEVEL)), '>', 1, 1)
                       ) tag
    FROM       export_jobs
    WHERE      exp_id =  p_exp_id
    CONNECT BY LEVEL <= (LENGTH (sql_stmt) - LENGTH (REPLACE (sql_stmt, '<')))Which I thought would be fine (having tested it on a text column). However, it runs very poorly against a clob column, for some reason (probably doesn't like the substr, instr, etc on the clob, at a guess) - the waits show "direct path read".
    When I cast the sql_stmt as a varchar2 like so:
    with my_tab as (select cast(substr(sql_stmt, instr(sql_stmt, '<', 1), instr(sql_stmt, '>', -1) - instr(sql_stmt, '<', 1) + 1) as varchar2(4000)) sql_stmt
                    from export_jobs
                    WHERE      exp_id = p_exp_id)
    SELECT     SUBSTR (sql_stmt,
                       INSTR (sql_stmt, '<', 1, LEVEL),
                       INSTR (substr(sql_stmt, INSTR (sql_stmt, '<', 1, LEVEL)), '>', 1, 1)
                       ) tag
    FROM       my_tab
    CONNECT BY LEVEL <= (LENGTH (sql_stmt) - LENGTH (REPLACE (sql_stmt, '<')))it runs blisteringly fast in comparison, except when the substr'd sql_stmt is over 4000 chars, of course! Using dbms_lob instr and substr etc doesn't help either.
    So, I thought maybe I could find an xml related method, and from this link:get xml node name in loop , I tried:
    select t.column_value.getrootelement() node
      from (select sql_stmt xml from export_jobs where exp_id = 28) xml,
    table (xmlsequence(xml.xml.extract('//*'))) tBut I get this error: ORA-22806: not an object or REF. (It might not be the way to go after all, as it's not proper xml, being as there are no corresponding close tags, but I was trying to think outside the box. I've not needed to use xml stuff before, so I'm a bit clueless about it, really!)
    I tried casting sql_stmt into an xmltype, but I got: ORA-22907: invalid CAST to a type that is not a nested table or VARRAY
    Is anyone able to suggest a better method of trying to extract my tags from the clob column, please?
    Message was edited by:
    Boneist

    I don't know if it may work for you, but I had a similar activity where I defined sql statements with bind variables (:var_name) and then I simply looked for witch variables to bind in that statement through this query.
    with x as (
         select ':var1
         /*a block comment
         :varname_dontcatch
         select hello, --line comment :var_no
              ''a string with double quote '''' and a :variable '',  --:variable
              :var3,
              :var2, '':var1'''':varno'',
         from dual'     as string
         from dual
    ), fil as (
         select string,
              regexp_replace(string,'(/\*[^*]*\*/)'||'|'||'(--.*)'||'|'||'(''([^'']|(''''))*'')',null) as res
         from x
    select string,res,
         regexp_substr(res,'\:[[:alpha:]]([[:alnum:]]|_)*',1,level)
    from fil
    connect by regexp_instr(res,'\:[[:alpha:]]([[:alnum:]]|_)*',1,level) > 0
    /Or through these procedures
         function get_binds(
              inp_string in varchar2
         ) return string_table
         deterministic
         is
              loc_str varchar2(32767);
              loc_idx number;
              out_tab string_table;
         begin
              --dbms_output.put_line('cond = '||inp_string);
              loc_str := regexp_replace(inp_string,'(/\*[^*]*\*/)'||'|'||'(--.*)'||'|'||'(''([^'']|(''''))*'')',null);
              loc_idx := 0;
              out_tab := string_table();
              --dbms_output.put_line('fcond ='||loc_str);
              loop
                   loc_idx := regexp_instr(loc_str,'\:[[:alpha:]]([[:alnum:]]|_)*',loc_idx+1);
                   exit when loc_idx = 0;
                   out_tab.extend;
                   out_tab(out_tab.last) := regexp_substr(loc_str,'[[:alpha:]]([[:alnum:]]|_)*',loc_idx+1);
              end loop;
              return out_tab;
         end;
         function divide_string (
              inp_string in varchar2
              --,inp_length in number
         --return string_table
         return dbms_sql.varchar2a
         is
              inp_length number := 256;
              loc_ind_1 pls_integer;
              loc_ind_2 pls_integer;
              loc_string_length pls_integer;
              loc_curr_string varchar2(32767);
              --out_tab string_table;
              out_tab dbms_sql.varchar2a;
         begin
              --out_tab := dbms_sql.varchar2a();
              loc_ind_1 := 1;
              loc_ind_2 := 1;
              loc_string_length := length(inp_string);
              while ( loc_ind_2 < loc_string_length ) loop
                   --out_tab.extend;
                   loc_curr_string := substr(inp_string,loc_ind_2,inp_length);
                   dbms_output.put(loc_curr_string);
                   out_tab(loc_ind_1) := loc_curr_string;
                   loc_ind_1 := loc_ind_1 + 1;
                   loc_ind_2 := loc_ind_2 + length(loc_curr_string);
              end loop;
              dbms_output.put_line('');
              return out_tab;
         end;
         function execute_statement(
              inp_statement in varchar2,
              inp_binds in string_table,
              inp_parameters in parametri
         return number
         is
              loc_stat dbms_sql.varchar2a;
              loc_dyn_cur number;
              out_rows number;
         begin
              loc_stat := divide_string(inp_statement);
              loc_dyn_cur := dbms_sql.open_cursor;
              dbms_sql.parse(c => loc_dyn_cur,
                   statement => loc_stat,
                   lb => loc_stat.first,
                   ub => loc_stat.last,
                   lfflg => false,
                   language_flag => dbms_sql.native
              for i in inp_binds.first .. inp_binds.last loop
                   DBMS_SQL.BIND_VARIABLE(loc_dyn_cur, inp_binds(i), inp_parameters(inp_binds(i)));
                   dbms_output.put_line(':'||inp_binds(i)||'='||inp_parameters(inp_binds(i)));
              end loop;
              dbms_output.put_line('');
              --out_rows := DBMS_SQL.EXECUTE(loc_dyn_cur);
              DBMS_SQL.CLOSE_CURSOR(loc_dyn_cur);
              return out_rows;
         end;Bye Alessandro
    Message was edited by:
    Alessandro Rossi
    There is something missing in the functions but if there is something that may interest you you can ask.

  • Cluster bar chart- sql query please help-

    Hi,
    I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
    Here is my table
    city     region      issue     value
    c1     north     i1     y
    c1     north     i2     y
    c2     north     i1     n
    c2     north     i2     y
    c3     south     i1     y
    c3     south     i2     n
    c4     east     i1     n
    c4     east     i2     n
    The bar chart will have 3 series, north south and east.
    And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
    How can I get something like this from the above table-
    region     issue     count(yes)
    north     i1     1
    north     i2     2
    south     i1     1
    south     i2     0
    east     i1     0
    east     i2     0
    thanks

    WITH table1 AS
    (SELECT 1435177 qte_id, 2 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no
    FROM dual
    table2 AS
    SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
    FROM dual
    SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
    FROM
    (SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
    FROM table1 t1, table2 t2
    WHERE t2.qte_id = t1.qte_id (+)
    AND t2.seq_no = t1.seq_no(+)
    ORDER BY 1,2
    WHERE t1_seq_no IS NOT NULL
    ORDER BY 1,2
    QTE_ID T2_SEQ_NO DIFF
    1435177 2 0
    1435177 5 0
    1435177 7 0
    1435177 8 0
    1435177 12 0
    1435177 14 0

  • Hey How Do I Get Group Message On The IPhone 4s because some reason it doesn't want to show . First i did is setting then messages  it only show imessage and message count )HELP)

    ey How Do I Get Group Message On The IPhone 4s because some reason it doesn't want to show . First i did is setting then messages  it only show imessage and message count )HELP)

    At the bottom of the page Settings > Messages you should have a section headed "SMS/MMS" Turn MMS messaging on then you can turn group message on.

  • How to improve the performance of the attached query, Please help

    Hi,
    How to improve performance of the below query, Please help. also attached explain plan -
    SELECT Camp.Id,
    rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount,
    (SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
    rCam.AccountKey as AccountKey
    FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
    WHERE Camp.AccountKey = rCam.AccountKey
    AND Camp.AvCampaignKey = rCam.AvCampaignKey
    AND Camp.AccountKey = CamBilling.AccountKey
    AND Camp.CampaignKey = CamBilling.CampaignKey
    AND rCam.AccountKey = xSite.AccountKey
    AND rCam.AvSiteKey = xSite.AvSiteKey
    AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
    to_date('01-01-2011', 'DD-MM-YYYY')
    GROUP By rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount
    Explain Plan :-
    Description                    Object_owner          Object_name     Cost     Cardinality     Bytes     
    SELECT STATEMENT, GOAL = ALL_ROWS                              14     1     13
    SORT AGGREGATE                                                  1     13
    VIEW                         GEMINI_REPORTING               14     1     13
    HASH GROUP BY                                        14     1     103
    NESTED LOOPS                                        13     1     103
    HASH JOIN                                             12     1     85
    TABLE ACCESS BY INDEX ROWID     GEMINI_REPORTING     RCAMSIT          2     4     100
    NESTED LOOPS                                        9     5     325
    HASH JOIN                                        7     1     40
    SORT UNIQUE                                        2     1     18
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          SITE          2     1     18
    INDEX RANGE SCAN          GEMINI_PRIMARY          SITE_I0          1     1     
    TABLE ACCESS FULL          GEMINI_PRIMARY          SITE          3     27     594
    INDEX RANGE SCAN          GEMINI_REPORTING     RCAMSIT_I     1     1     5     
    TABLE ACCESS FULL     GEMINI_PRIMARY     CAMPAIGN                    3     127     2540
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          CAMBILLING     1     1     18
    INDEX UNIQUE SCAN     GEMINI_PRIMARY     CAMBILLING_U1                    0     1

    Hello,
    This has really nothing to do with the Oracle Forms product.
    Please, send the SQL or/and PL/SQL questions in the corresponding forums.
    Francois

  • Dynamic SQL Query count

    Hi,
    I need to retieve the number of records that will be retrieved by a query as follows.
    How can this be done?
    Is there a method to do it using native dynamic sql (open .. for .. using ) instead of DBMS_SQL (Because Native is faster than dbms_SQL )?
    The following block demostrates what I need to do where v_query will hold the query text.
    declare
    v_query varchar2(32000);
    v_count number;
    begin
    select query_text into v_query from groups_table where id =1;
    dbms_output.put_line('count = '||v_count);
    end;
    Thanks in Advance

    Is there a way to use sql%rowcount to do something similar?
    Afraid not
    I mean if there is a way to get better performance in case of very large query. Like for example in oracle forms, when using Query --> count records it retrieves the nubmer of records that will be fetched.
    I think you'll find forms simply does a select count(*) from the base table (adding and predicates where necessary).
    What are you going to use it for? Maybe there is an alternative route you can take...

  • Max Query Count setting

    Hello colleagues,
    Probably you many know there is Max Query Count setting in MII.
    Does any of you experience performance concerns by dealing with large number of query count?  or does any of you have a recommendation for how to set max query count, e.g. not exceeding memory size to avoid memory swapping? 
    my customer want to increase this max count due to fluctuating record count.  but they have concerns on such disadvantage in performance.
    any of your experiences are welcome.  Thank you,
    Shiroh Kinoshita, SAP Japan

    Shiroh,
    Good to hear from you.
    All queries have the RowCount setting, but we typically discourage people from just setting it to a high number.  In some cases the data servers will limit this number to a max (something like 250000) but that doesn't mean that from a memory standpoint, or a customer patience level (especially in the browser) would ever get to that number of records.
    Where is it that you are seeing the record count fluctuate, applets in the browser, query actions in a transaction?
    What is it that makes the customer want to increase this to a high number?
    Regards,
    Jeremy

  • 919: Column count replaces query count when opening table/view/etc tab

    I don't know whether this is intentional or not, but I have just noticed that opening a table or view tab from the connection pane replaces the existing query count message with the query count from the column query. For example, opening a table tab for a table with 14 columns sets the query count message to "All Rows Fetched: 14".
    This is not a big issue, but adds to the aggravation of only having the latest query count message, rather than one for each SQL Worksheet.
    Is it possible to find somewhere on the SQL Worksheet that we can put it's query count message (for example to the right of the execution time)?

    I am happy for querying the columns of a table/view/etc to display the fetch count of the columns, although I am rarely interested in how many columns there are in a table/view/etc.
    However, I already find it frustrating that the query count is only for the last fetch - it can be very useful having the query count for last fetch per SQL Worksheet. Having the last fetch overwritten by opening a table tab only makes it more frustrating.

  • Query of Query count(column) returns blank not zero

    This appears to be a bug in 7,0,1,116466 and 8,0,1,195765
    Query of Query count(column) or count(*) returns blank not
    zero when there are no matches. Properly returns a number when
    there are query matches.
    e.g. select count(i_id) from PersonnelQuery where i_id <
    100
    Where does one report these?

    scottcook,
    This was a known bug in ColdFusion 6.x which has apparently
    not been fixed.
    Bug in CF6 (See the Comments section of the page linked
    below)
    http://livedocs.adobe.com/coldfusion/6.1/htmldocs/using_29.htm
    Workaround
    http://www.bennadel.com/blog/244-ColdFusion-Query-Of-Queries-Odd-COUNT-Behavior.htm
    To report this as a bug
    http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

  • Query counter : event 3100 not logged in table RSDDSTAT_OLAP

    Hi experts,
    We have a customer scenario where in the table RSDDSTAT_OLAP table is not getting populated with the eventID '3100' when a query is executed. Due to this the query counter is not getting any value ( according to extractor logic RSTC_BIRS_OLAP_AGGREGATED_DATA)
    The changes of the notes : 1250182 ,1505325, 1093755 are already present in the cutomer system.
    Hence would like to know the cases in which OLAP read eventid 000003100 would not get recorded in the table RSDDSTAT_OLAP, on execution of the query .
    Thanks in Advance,
    Keerthi

    Hi,
    It's a good decision you made because you shouldn't create objects in the SYS schema. I see you're using the add_job_email_notification procedure, so I'm assuming you're on 11g onwards.
    This procedure is meant to make the job easy for you. That is, you don't need to worry about setting up AQ, the procedure does it all for you. All you need to do is setup the mail server if not already done, and call this procedure to add the mail notification. That's it.
    You can also specify a filter to the add_job_email_notification procedure, so maybe you could specify directly your CLIENT.LOAD_DATA job to this procedure.

  • Can't Return Count of Orders Hour By Hour in Query Please Help

    Below is the query i am running currently. It allows you to select the Date and Time from a form and returns a total # of orders between the selected Date and times. What i need it to further break down per hour the number of orders. So if pick 08/06/2012 05:00:00 to 08/06/2012 11:00:00 it should show me the number of orders per Hour. Where currently it totals the orders for the entire time selected
    This query currently works but does not break it down per hour unless i select 08/06/2012 05:00:00 to 08/06/2012 06:00:00 and then repeat for each hour. Which is very time consuming.
    Any and all help would be amazing as i have been at this for weeks.
    SELECT
    ROUND(SUM(COUNTWEIGHT)) ENTITIES, Z.NAME ZONE
    FROM
    PPSDBA.ARCH_RX RX,
    PPSDBA.ARCH_VIAL_CONTENTS AVC,
    PPSDBA.ZONE Z,
    (SELECT 1 / COUNT(RX.TOTE_ORDER_ID) COUNTWEIGHT, RX.TOTE_ORDER_ID ORDERID
    FROM PPSDBA.ARCH_RX RX,
    PPSDBA.ARCH_VIAL_CONTENTS AVC,
    PPSDBA.ARCH_VIAL AV
    WHERE AV.RX_ID=RX.RX_ID AND
    AVC.VIAL_ID = AV.VIAL_ID AND
    RX.FILLED_TYPE NOT IN (19,20) and
    AVC.FILL_DATE  BETWEEN TO_DATE('#DATE_FROM#' , 'MM/DD/YYYY hh24:mi') AND TO_DATE('#DATE_TO#' , 'MM/DD/YYYY hh24:mi')
    GROUP BY RX.TOTE_ORDER_ID) SUBQUERY,
    PPSDBA.ARCH_VIAL AV
    WHERE
    SUBQUERY.ORDERID=RX.TOTE_ORDER_ID AND
    AV.RX_ID=RX.RX_ID AND
    RX.FILLED_TYPE = Z.ZONE_ID AND
    AVC.VIAL_ID = AV.VIAL_ID AND
    RX.FILLED_TYPE NOT IN (19,20) and
    AVC.FILL_DATE BETWEEN TO_DATE('#DATE_FROM#' , 'MM/DD/YYYY hh24:mi') AND TO_DATE('#DATE_TO#' , 'MM/DD/YYYY hh24:mi')
    GROUP BY Z.NAME

    Hi,
    951094 wrote:
    Below is the query i am running currently. It allows you to select the Date and Time from a form and returns a total # of orders between the selected Date and times.Rit's giving you a separrate total for each distinct value of z.name; that's waht
    GROUP BY Z.NAMEdoes.
    What i need it to further break down per hour the number of orders. To get a separate total for each distinct combination of name and hour, you need to change that to something like
    GROUP BY  z.name
    ,         TRUNC (fill_date, 'HH')Make sure fill_date is included in the underlyiong result set. It looks like that result set is based on another GROUP BY, so you'll need to include TRUNC (fill_date) in that GROUP BY clause, also.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • Query HINT help requested Pls.

    A query thus:
    SELECT equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    FROM v_stocked_equipment_inven_his vsdeih,
    v_stock_equipment_mod_man_list vsemml
    WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
    AND equipment_status_code IN
    ('ALL', 'AVA' )
    AND ec_end_date IS NULL
    AND eav_end_date IS NULL
    GROUP BY equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    HAVING COUNT (model_attribute_value_id) =
    (SELECT COUNT (*)
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    WHERE stock_equipment_id =
    vsemml.stock_equipment_id);
    has result :
    513 rows selected.
    Elapsed: 00:04:59.17
    Execution Plan
    Plan hash value: 3816309895
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 240 | 21120 | | 38010 (7)| 00:07:37 |
    |* 1 | FILTER | | | | | | |
    | 2 | HASH GROUP BY | | 240 | 21120 | | 38010 (7)| 00:07:37 |
    |* 3 | FILTER | | | | | | |
    |* 4 | HASH JOIN OUTER | | 23915 | 2055K| | 38006 (7)| 00:07:37 |
    |* 5 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
    | 6 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
    | 7 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    | 8 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 23915 | 1704K| | 37998 (7)| 00:07:36 |
    | 9 | HASH UNIQUE | | 23915 | 2989K| 6392K| 37998 (7)| 00:07:36 |
    |* 10 | HASH JOIN RIGHT OUTER | | 23915 | 2989K| | 37307 (7)| 00:07:28 |
    | 11 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
    |* 12 | HASH JOIN RIGHT OUTER | | 23915 | 2849K| | 37303 (7)| 00:07:28 |
    | 13 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
    |* 14 | HASH JOIN | | 23915 | 2615K| | 37297 (7)| 00:07:28 |
    | 15 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 16 | 128 | | 3 (0)| 00:00:01 |
    |* 16 | HASH JOIN | | 23915 | 2428K| | 37293 (7)| 00:07:28 |
    | 17 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    |* 18 | HASH JOIN | | 645K| 60M| | 37278 (7)| 00:07:28 |
    | 19 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
    |* 20 | HASH JOIN | | 5288K| 458M| 9M| 37180 (7)| 00:07:27 |
    | 21 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 297K| 6672K| | 784 (3)| 00:00:10 |
    |* 22 | HASH JOIN | | 7467K| 484M| 6328K| 5447 (5)| 00:01:06 |
    | 23 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
    |* 24 | HASH JOIN | | 380K| 22M| 4528K| 3235 (2)| 00:00:39 |
    |* 25 | HASH JOIN | | 140K| 2876K| | 563 (2)| 00:00:07 |
    | 26 | MERGE JOIN | | 281 | 3372 | | 6 (17)| 00:00:01 |
    | 27 | TABLE ACCESS BY INDEX ROWID| SITE_TYPE | 4 | 20 | | 2 (0)| 00:00:01 |
    | 28 | INDEX FULL SCAN | PK_SITE_TYPE | 4 | | | 1 (0)| 00:00:01 |
    |* 29 | SORT JOIN | | 281 | 1967 | | 4 (25)| 00:00:01 |
    | 30 | VIEW | index$_join$_016 | 281 | 1967 | | 3 (0)| 00:00:01 |
    |* 31 | HASH JOIN | | | | | | |
    | 32 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 33 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 34 | TABLE ACCESS FULL | LOCATION | 140K| 1232K| | 554 (2)| 00:00:07 |
    | 35 | TABLE ACCESS FULL | EQUIPMENT_CONFIGURATION | 380K| 15M| | 1460 (2)| 00:00:18 |
    | 36 | SORT AGGREGATE | | 1 | 6 | | | |
    | 37 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
    |* 38 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 39 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
    "STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
    "STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
    3 - filter(("EQUIPMENT_STATUS_CODE"='ALL' OR "EQUIPMENT_STATUS_CODE"='AVA') AND "EC_END_DATE" IS NULL AND "EAV_END_DATE"
    IS NULL)
    4 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID"(+))
    5 - access("SE"."MODEL_ID"="M"."MODEL_ID")
    10 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
    12 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
    14 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
    16 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID" AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    18 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID")
    20 - access("EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
    filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
    "EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
    IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
    22 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
    24 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
    25 - access("L"."SITE_ID"="S"."SITE_ID")
    29 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    filter("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    31 - access(ROWID=ROWID)
    38 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
    39 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
    Query altered to:
    =================
    SELECT equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    FROM v_stocked_equipment_inven_his vsdeih,
    v_stock_equipment_mod_man_list vsemml
    WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
    AND equipment_status_code = 'ALL'
    AND ec_end_date IS NULL
    AND eav_end_date IS NULL
    GROUP BY equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    HAVING COUNT (model_attribute_value_id) =
    (SELECT COUNT (*)
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    WHERE stock_equipment_id =
    vsemml.stock_equipment_id)
    union
    SELECT equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    FROM v_stocked_equipment_inven_his vsdeih,
    v_stock_equipment_mod_man_list vsemml
    WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
    AND equipment_status_code = 'AVA'
    AND ec_end_date IS NULL
    AND eav_end_date IS NULL
    GROUP BY equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    HAVING COUNT (model_attribute_value_id) =
    (SELECT COUNT (*)
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    WHERE stock_equipment_id =
    vsemml.stock_equipment_id);
    Results in:
    513 rows selected.
    Elapsed: 00:00:07.40
    Execution Plan
    Plan hash value: 3317078232
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 2 | 176 | | 6431 (51)| 00:01:18 |
    | 1 | SORT UNIQUE | | 2 | 176 | | 6431 (51)| 00:01:18 |
    | 2 | UNION-ALL | | | | | | |
    |* 3 | FILTER | | | | | | |
    | 4 | HASH GROUP BY | | 1 | 88 | | 3216 (2)| 00:00:39 |
    |* 5 | HASH JOIN | | 95 | 8360 | | 3214 (2)| 00:00:39 |
    |* 6 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
    | 7 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
    | 8 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    | 9 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 95 | 6935 | | 3207 (2)| 00:00:39 |
    | 10 | HASH UNIQUE | | 95 | 12160 | | 3207 (2)| 00:00:39 |
    |* 11 | HASH JOIN RIGHT OUTER | | 95 | 12160 | | 3206 (2)| 00:00:39 |
    | 12 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
    |* 13 | HASH JOIN OUTER | | 95 | 11590 | | 3202 (2)| 00:00:39 |
    |* 14 | HASH JOIN | | 95 | 10640 | | 3196 (2)| 00:00:39 |
    | 15 | TABLE ACCESS FULL | SITE_TYPE | 4 | 20 | | 3 (0)| 00:00:01 |
    |* 16 | HASH JOIN | | 95 | 10165 | | 3193 (2)| 00:00:39 |
    | 17 | VIEW | index$_join$_021 | 281 | 1967 | | 3 (0)| 00:00:01 |
    |* 18 | HASH JOIN | | | | | | |
    | 19 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 20 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 21 | NESTED LOOPS | | 95 | 9500 | | 3189 (2)| 00:00:39 |
    |* 22 | HASH JOIN | | 96 | 8736 | 4440K| 3093 (2)| 00:00:38 |
    |* 23 | HASH JOIN | | 56789 | 3771K| | 1679 (2)| 00:00:21 |
    |* 24 | HASH JOIN | | 2894 | 178K| | 1273 (1)| 00:00:16 |
    | 25 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
    |* 26 | HASH JOIN | | 2894 | 158K| | 1271 (1)| 00:00:16 |
    | 27 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    |* 28 | TABLE ACCESS BY INDEX ROWID| EQUIPMENT_CONFIGURATION | 1279 | 53718 | | 1265 (1)| 00:00:16 |
    | 29 | NESTED LOOPS | | 1860 | 93000 | | 1268 (1)| 00:00:16 |
    |* 30 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 1 | 8 | | 3 (0)| 00:00:01 |
    |* 31 | INDEX RANGE SCAN | XIF3EQUIPMENT_CONFIGURATION | 23796 | | | 48 (3)| 00:00:01 |
    | 32 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
    |* 33 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 242K| 5451K| | 785 (3)| 00:00:10 |
    | 34 | TABLE ACCESS BY INDEX ROWID | LOCATION | 1 | 9 | | 1 (0)| 00:00:01 |
    |* 35 | INDEX UNIQUE SCAN | PK_LOCATION | 1 | | | 0 (0)| 00:00:01 |
    | 36 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
    | 37 | SORT AGGREGATE | | 1 | 6 | | | |
    | 38 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
    |* 39 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 40 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 41 | FILTER | | | | | | |
    | 42 | HASH GROUP BY | | 1 | 88 | | 3216 (2)| 00:00:39 |
    |* 43 | HASH JOIN | | 95 | 8360 | | 3214 (2)| 00:00:39 |
    |* 44 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
    | 45 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
    | 46 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    | 47 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 95 | 6935 | | 3207 (2)| 00:00:39 |
    | 48 | HASH UNIQUE | | 95 | 12160 | | 3207 (2)| 00:00:39 |
    |* 49 | HASH JOIN RIGHT OUTER | | 95 | 12160 | | 3206 (2)| 00:00:39 |
    | 50 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
    |* 51 | HASH JOIN OUTER | | 95 | 11590 | | 3202 (2)| 00:00:39 |
    |* 52 | HASH JOIN | | 95 | 10640 | | 3196 (2)| 00:00:39 |
    | 53 | TABLE ACCESS FULL | SITE_TYPE | 4 | 20 | | 3 (0)| 00:00:01 |
    |* 54 | HASH JOIN | | 95 | 10165 | | 3193 (2)| 00:00:39 |
    | 55 | VIEW | index$_join$_044 | 281 | 1967 | | 3 (0)| 00:00:01 |
    |* 56 | HASH JOIN | | | | | | |
    | 57 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 58 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 59 | NESTED LOOPS | | 95 | 9500 | | 3189 (2)| 00:00:39 |
    |* 60 | HASH JOIN | | 96 | 8736 | 4440K| 3093 (2)| 00:00:38 |
    |* 61 | HASH JOIN | | 56789 | 3771K| | 1679 (2)| 00:00:21 |
    |* 62 | HASH JOIN | | 2894 | 178K| | 1273 (1)| 00:00:16 |
    | 63 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
    |* 64 | HASH JOIN | | 2894 | 158K| | 1271 (1)| 00:00:16 |
    | 65 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    |* 66 | TABLE ACCESS BY INDEX ROWID| EQUIPMENT_CONFIGURATION | 1279 | 53718 | | 1265 (1)| 00:00:16 |
    | 67 | NESTED LOOPS | | 1860 | 93000 | | 1268 (1)| 00:00:16 |
    |* 68 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 1 | 8 | | 3 (0)| 00:00:01 |
    |* 69 | INDEX RANGE SCAN | XIF3EQUIPMENT_CONFIGURATION | 23796 | | | 48 (3)| 00:00:01 |
    | 70 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
    |* 71 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 242K| 5451K| | 785 (3)| 00:00:10 |
    | 72 | TABLE ACCESS BY INDEX ROWID | LOCATION | 1 | 9 | | 1 (0)| 00:00:01 |
    |* 73 | INDEX UNIQUE SCAN | PK_LOCATION | 1 | | | 0 (0)| 00:00:01 |
    | 74 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
    | 75 | SORT AGGREGATE | | 1 | 6 | | | |
    | 76 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
    |* 77 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 78 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    3 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
    "STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
    "STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
    5 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID")
    6 - access("SE"."MODEL_ID"="M"."MODEL_ID")
    11 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
    13 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
    14 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    16 - access("L"."SITE_ID"="S"."SITE_ID")
    18 - access(ROWID=ROWID)
    22 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID" AND
    "EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
    filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
    "EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
    IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
    23 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
    24 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    26 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID")
    28 - filter("EC"."END_DATE" IS NULL)
    30 - filter("ES"."EQUIPMENT_STATUS_CODE"='ALL')
    31 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
    33 - filter("EAV"."END_DATE" IS NULL)
    35 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
    39 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
    40 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
    41 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
    "STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
    "STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
    43 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID")
    44 - access("SE"."MODEL_ID"="M"."MODEL_ID")
    49 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
    51 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
    52 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    54 - access("L"."SITE_ID"="S"."SITE_ID")
    56 - access(ROWID=ROWID)
    60 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID" AND
    "EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
    filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
    "EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
    IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
    61 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
    62 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    64 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID")
    66 - filter("EC"."END_DATE" IS NULL)
    68 - filter("ES"."EQUIPMENT_STATUS_CODE"='AVA')
    69 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
    71 - filter("EAV"."END_DATE" IS NULL)
    73 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
    77 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
    78 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
    5 minutes reduced to 7 seconds.!!
    THE QUESTION.
    Which (and where) query hint do I use to get the FIRST query to use the execution plan "method" of the second -
    IE: To still perform well when a IN-LIST is used instead of EQUALS.
    Technical:
    Oracle 10.2.0.2 EE on Solaris 8, 64 bit.
    Please help.
    Thank you.
    Below is the code of the referenced views for clarity.
    CREATE OR REPLACE FORCE VIEW etrak.v_stocked_equipment_inven_his (stock_equipment_id,
    equipment_id,
    model_id,
    gameset_id,
    gameset_is_active,
    game_ware_id,
    game_ware_is_active,
    equipment_status_code,
    ec_start_date,
    ec_end_date,
    eav_start_date,
    eav_end_date,
    model_attribute_value_id,
    site_id,
    is_store
    AS
    SELECT DISTINCT stock_equipment_id, equipment_id, model_id, gameset_id,
    gameset_is_active, game_ware_id, game_ware_is_active,
    equipment_status_code, ec_start_date, ec_end_date,
    eav_start_date, eav_end_date, model_attribute_value_id,
    site_id, is_store
    FROM (SELECT stock_equipment_id, equipment_id, model_id,
    gameset_id, gameset_is_active, game_ware_id,
    game_ware_is_active, equipment_status_code,
    ec_start_date, ec_end_date, eav_start_date,
    eav_end_date, model_attribute_value_id, site_id,
    is_store
    FROM (SELECT DISTINCT equipment_id, model_id,
    gameset_id, gameset_is_active,
    game_ware_id, game_ware_is_active,
    equipment_status_code,
    model_attribute_value_id,
    ec_start_date, ec_end_date,
    eav_start_date, eav_end_date,
    site_id, is_store
    FROM (SELECT ec.equipment_id,
    ec.model_id,
    gs.gameset_id,
    gs.active_flag
    AS gameset_is_active,
    gw.game_ware_id,
    gw.active_flag
    AS game_ware_is_active,
    es.equipment_status_code,
    ec.start_date
    AS ec_start_date,
    ec.end_date
    AS ec_end_date,
    l.site_id, st.is_store
    FROM equipment_configuration ec,
    equipment_status es,
    LOCATION l,
    site s,
    site_type st,
    gameset gs,
    game_ware gw
    WHERE ec.equipment_status_id =
    es.equipment_status_id
    AND ec.gameset_id = gs.gameset_id(+)
    AND gs.game_ware_id = gw.game_ware_id(+)
    AND ec.location_id =
    l.location_id
    AND l.site_id = s.site_id
    AND s.site_type_id =
    st.site_type_id)
    JOIN
    (SELECT ec.equipment_id,
    model_attribute_value_id,
    eav.start_date
    AS eav_start_date,
    eav.end_date
    AS eav_end_date
    FROM equipment_configuration ec,
    equipment_attribute_value eav
    WHERE ec.equipment_id =
    eav.equipment_id)
    USING (equipment_id)
    WHERE ( eav_start_date >=
    ec_start_date
    AND ( ( eav_end_date IS NULL
    AND ec_end_date >=
    eav_start_date
    OR ec_end_date IS NULL
    OR eav_end_date <=
    ec_end_date
    OR ( ec_start_date >=
    eav_start_date
    AND ( ( ec_end_date IS NULL
    AND eav_end_date >=
    ec_start_date
    OR eav_end_date IS NULL
    OR ec_end_date <=
    eav_end_date
    JOIN
    (SELECT stock_equipment_id, model_id,
    model_attribute_value_id
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    ) USING (model_id,
    model_attribute_value_id)
    CREATE OR REPLACE FORCE VIEW etrak.v_stock_equipment_mod_man_list (stock_equipment_id,
    stock_equipment_code,
    model_id,
    model_name,
    model_type_id,
    model_type_code,
    model_type_name,
    man_id,
    man_name
    AS
    SELECT se.stock_equipment_id, se.stock_equipment_code, m.model_id,
    m.model_name, mt.model_type_id, mt.model_type_code,
    mt.model_type_name, ma.man_id, ma.man_name
    FROM stock_equipment se, model m, model_type mt, manufacturer ma
    WHERE se.model_id = m.model_id
    AND m.model_type_id = mt.model_type_id
    AND m.man_id = ma.man_id;

    What also makes it difficult to read is the lack of formatting tags ([code][/code] or [pre][/pre]) so that we can actually read the code and execution plans.
    I'm not going to trawl through formatting all that myself just to try and see what the differences are between query 1 and query 2.
    Also bear in mind that when query 2 ran, the data may have been cached and so there is less physical I/O required.
    You don't really want to use any hints to cause re-use of execution plans from 1 query to a different query (like I said, I don't know how different they are). What you want to do is determine what poor SQL coding is making the first query slow and fix it.

  • How to rewrite this query without sub query please help me

    Hello All Good Evening,
    Could you please help me with this query, how can i write this query without sub query, or how can write this query another ways
    please help me
    select planno, status1, count(*) Counts from
    select a.ValetNO PlanNo  ,
    case 
         when JoinCode in ('00', '01', '02') then 'Actcess'
         when JoinCode in ('20', '21', '22', '23','38', '39') then
         'Secured' else 'Other' end Status1 ---, COUNT (*)
       from  dbo.ppt a(NOLOCK)  left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO  = b.ValetNO
    --group by a.ValetNO
      a group by planno, status1
    order by 2
    Thank you in Advance
    Milan

    Whats your objective here? Sorry, am not able to understand the reason for this change. 
    Try the below:(Not tested)
    ;With cte
    As
    select a.ValetNO PlanNo ,
    case
    when JoinCode in ('00', '01', '02') then 'Actcess'
    when JoinCode in ('20', '21', '22', '23','38', '39') then
    'Secured' else 'Other' end Status1 ---, COUNT (*)
    from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
    select planno, status1, count(*) Counts from cte
    a group by planno, status1
    order by 2
    Even below:
    select a.ValetNO PlanNo ,
    case
    when JoinCode in ('00', '01', '02') then 'Actcess'
    when JoinCode in ('20', '21', '22', '23','38', '39') then
    'Secured' else 'Other' end Status1 , COUNT (1)
    from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
    Group by a.ValetNO ,
    case
    when JoinCode in ('00', '01', '02') then 'Actcess'
    when JoinCode in ('20', '21', '22', '23','38', '39') then
    'Secured' else 'Other' end

  • JOIN/QUERY/VIEW Help

    Hi guys, i'm new to the forum. currently i'm taking a computer information tech diploma course and am in entry level database.
    Ive struggled my way through this assignment.. I don't want free answers but im done everything except one view and a bonus question. Can someone help me ? not just the answer but an explination.. I'm finding Joins and Subqueries very hard to wrap my head around.. anyways here are the two questions:
    6) To help the front desk clerk do guest billings, [a - 6 marks, b - 2 marks]
    (a) create a view to calculate the account (i.e. running total todate) for each guest at the Grosvenor Hotel; the view should include the room number, guest name, check-in date, check-out date (today), room rate, the duration in days, and the calculated total dollars
    (b) write a SELECT query to demonstrate your view (Use 2007-10-09 as current date if needed).
    Optional Bonus Question: up to 10 marks but restricted by allowable maximum for course:
    7) Find the most commonly booked room type(s) for each hotel in London? For each hotel, list the hotel number, room type and the number of bookings.
    Here are the tables, let me know if you need the data inserted.
    CREATE TABLE Hotel
    (hotelNo NUMBER(4) NOT NULL
    ,hotelName VARCHAR2(16) NOT NULL
    ,hotelAddress VARCHAR2(40) NOT NULL
    ,PRIMARY KEY (hotelNo)
    CREATE TABLE Room
    (hotelNo NUMBER(4) NOT NULL
    ,roomNo NUMBER(4) NOT NULL
    ,type VARCHAR2(8) NOT NULL
    ,price NUMBER(6,2) NOT NULL
    ,PRIMARY KEY (hotelNo, roomNo)
    CREATE TABLE Guest
    (guestNo NUMBER(4) NOT NULL
    ,guestName VARCHAR2(15) NOT NULL
    ,guestAddress VARCHAR2(40) NOT NULL
    ,PRIMARY KEY (guestNo)
    CREATE TABLE Booking
    (hotelNo NUMBER(4) NOT NULL
    ,guestNo NUMBER(4) NOT NULL
    ,dateFrom DATE NOT NULL
    ,dateTo DATE
    ,roomNo NUMBER(4) NOT NULL
    ,PRIMARY KEY (hotelNo, guestNo, dateFrom)
    thank you, and go easy :}
    Edit/Delete Message

    John CIT,
    I would advise you to visit here
    http://www.oracle.com/pls/db92/db92.federated_search
    You will information regarding creating views, etc.
    After reading the documentation if you still have
    doubts. Then please ask.
    The whole point at least from my end is that I should
    see some of your effort too for the problem that has
    been stated.
    Good luck
    AdithI agree, ive tried to make both work and failed or else i wouldnt have posted..
    I know for the view (#6) I have to select guestNo, roomNo, dateFrom, dateTo, price, dateFrom, price*(dateFrom-dateTo).. im just not sure how to join them all together properly.
    for #7 im going to have to use a count aggregate from rooms in the booking table thats joined with Hotel..
    ive been working on this man im just confused. at least point me in the right direction?
    thanks for response

  • Sql Count Help

    Hi Everyone,
    I need to display SPER_STATUS_TEXT count as 0 if there is no data for below Query. Could someone please help me
    SQL> SELECT a.sper_status_text, COUNT ( * )
    2 FROM (SELECT sper.assettxt,
    3 CASE
    4 WHEN sper.sper_status_text = 'Affirmed Evaluation'
    5 THEN
    6 'Affirmed Evaluation'
    7 WHEN sper.sper_status_text LIKE 'Updated - Evaluated Up%'
    8 THEN
    9 'Updated - Evaluated Up'
    10 WHEN sper.sper_status_text LIKE 'Updated - Evaluated Down%'
    11 THEN
    12 'Updated - Evaluated Down'
    13 ELSE
    14 'Other Responses'
    15 END
    16 sper_status_text
    17 FROM zzcus.zzcus_sper_data sper
    18 WHERE sper.sper_dates = '20100801--20100831'
    19 AND sper.customer_id = 'NATFINS'
    20 AND sper.task_inquiry_type = 'Vendor Comparison'
    21 AND sper.assettxt <> '!NA'
    22 ) a
    23 GROUP BY a.sper_status_text
    24 ORDER BY (CASE
    25 WHEN a.sper_status_text = 'Affirmed Evaluation' THEN 1
    26 WHEN a.sper_status_text = 'Updated - Evaluated Up' THEN 2
    27 WHEN a.sper_status_text = 'Updated - Evaluated Down' THEN 3
    28 ELSE 4
    29 END);
    Results:
    SPER_STATUS_TEXT COUNT(*)
    Affirmed Evaluation 2
    I need to display like below (if there is no data I need to display count as 0)
    SPER_STATUS_TEXT COUNT(*)
    Affirmed Evaluation 2
    Updated - Evaluated Up 0
    Updated - Evaluated Down 0
    Other Responses 0
    Please Advice

    You can get it like this. By using MODEL clause,
    SQL>
    SQL> CREATE TABLE ZZCUS_SPER_DATA1
      2  (
      3     SPER_STATUS_TEXT VARCHAR2 (30)
      4    ,TASK_INQUIRY_TYPE VARCHAR2 (100)
      5  );
    Table created.
    SQL>
    SQL> INSERT INTO ZZCUS_SPER_DATA1
      2       VALUES (
      3                 'Data Updated', 'Descriptive Data Challenge - Maturity date / Redemption date');
    1 row created.
    SQL>
    SQL> INSERT INTO ZZCUS_SPER_DATA1
      2       VALUES ('Data Updated', 'Descriptive Data Challenge - Ticker / Local Code');
    1 row created.
    SQL>
    SQL> SELECT *
      2    FROM (  SELECT A.SPER_STATUS_TEXT, COUNT (*) CNT
      3              FROM (SELECT CASE
      4                              WHEN SPER.SPER_STATUS_TEXT = 'Data Confirmed'
      5                              THEN
      6                                 'Data Item Confirmed'
      7                              WHEN SPER.SPER_STATUS_TEXT LIKE 'Data Updated'
      8                              THEN
      9                                 'Data Item Updated'
    10                              ELSE
    11                                 'Other Responses'
    12                           END
    13                              SPER_STATUS_TEXT
    14                      FROM ZZCUS_SPER_DATA1 SPER
    15                     WHERE 1 = 1
    16                           AND SPER.TASK_INQUIRY_TYPE LIKE 'Descriptive Data Challenge%') A
    17          GROUP BY A.SPER_STATUS_TEXT
    18          ORDER BY (CASE
    19                       WHEN A.SPER_STATUS_TEXT = 'Data Item Confirmed' THEN 1
    20                       WHEN A.SPER_STATUS_TEXT = 'Data Item Updated' THEN 2
    21                       WHEN A.SPER_STATUS_TEXT = 'Other Responses' THEN 3
    22                       ELSE 4
    23                    END))
    24  MODEL
    25     DIMENSION BY (SPER_STATUS_TEXT)
    26     MEASURES (CNT)
    27     RULES
    28        (CNT ['Data Item Confirmed'] = NVL (CNT[CV ()], 0),
    29        CNT ['Data Item Updated'] = NVL (CNT[CV ()], 0),
    30        CNT ['Other Responses'] = NVL (CNT[CV ()], 0));
    SPER_STATUS_TEXT           CNT
    Data Item Updated            2
    Other Responses              0
    Data Item Confirmed          0
    3 rows selected.
    SQL> G.

Maybe you are looking for

  • Color printing with high resolution in smartforms

    Hello colleagues... I need to print color images with True-color resolution, but in Form Graphics Administrator ( transaction SE78 ) I can only upload pictures with extension TIFF and BMP, and with resolution 24-bit maximum. With this resolution, the

  • Rollback related queries

    I have doubt related to rollback in albpm. though we have COMPENSATION HANDLDLING method to deal with rollbacks but what if we make an entry in databse and we have to rollback the changes. I tried it using compensation handling but i dont think that

  • NEED HELP WITH RESOLUTION AND QUALITY?

    hi guys i have been making these vector type portraits in photoshop for the last couple weeks, it has all been going well until, when some one puts it up as a display picture on facebook etc the quality is not as good as when i just view the picture

  • How do I sync all other items when iPhoto library offline?

    I have an iPhoto library which is on an external drive and not always connected to my MacBook Air. Previous to iOS 5.x and the related iTunes 10.5.x, I am fairly certain that I was able to perform a full sync to the iPhone (songs, apps, podcasts, vid

  • Dynamic Table UI without wdDoModifyView

    Dear Friends, I have 2 tables in a single view. As per the line item choice made on the first table, the second table to need to rebuild with columns and data. I am successful doing this for a one time since code is written at wdDoModifyView method.