Mysql equivalent oracle sql query is required

Hi all,
please help me convert mysql quyery into sql query.
select u.username, t.name as fullname, p.id as project_id, p.name as project,
                         (select count(a.resource_id) from pd_resource_task_alloc as a left OUTER JOIN pd_resource_task as b on a.task_id=b.task_id where a.task_id=t.id )  as allocatedTask,
                         (select count(a.resource_id) from pd_resource_task_alloc as a left OUTER JOIN pd_resource_task as b on a.task_id=b.task_id where a.task_id=t.id and b.task_status_id='2') as completedTask,
                         (select count(a.resource_id) from pd_resource_task_alloc as a left OUTER JOIN pd_resource_task as b on a.task_id=b.task_id where a.task_id=t.id and b.task_status_id!='2') as pendingTask,
                         c.name as category, sub.task_id, t.name, sub.bucket_date, sum(sub.alloc_time) as s
                         from (select rt.task_id, rt.resource_id, rt.project_id, rta.sequence, rta.alloc_time,DATE(th.creation_date) as creation_date,rt.start_date,th.task_status_id,rt.start_date as bucket_date from resource_task rt, resource_task_alloc rta ,task_history th
                         where rt.task_id = rta.task_id and rt.task_id = th.task_id and th.task_status_id >=2
                         and rt.resource_id = rta.resource_id and rt.project_id = rta.project_id
                         and rta.alloc_time > 0 and rt.start_date is not null ) as sub,
                         pd_tool_user u, pd_task t, pd_project p, pd_category c where sub.resource_id = u.id
                         and sub.start_date >='2011-11-01' and sub.creation_date <= '2011-11-31'
                         and sub.task_id = t.id and sub.project_id = p.id and
                         t.category_id = c.id
                         and sub.project_id='355'
                         group by p.project, u.username, p.id , u.name, sub.task_id, t.name, c.name,
                         sub.bucket_date order by u.username, sub.bucket_date, p.name, c.nameThanks,
P Prakash

Not sure as we don't have any tables and data to work with, but firstly...
a) format your code to make it easier to see what's going on
b) don't mix ansi joins with regular joins
c) treat DATEs as DATEs
d) Table alias names don't use the "AS" keyword
First guess (obviously unteseted)...
select u.username
      ,t.name as fullname
      ,p.id as project_id
      ,p.name as project
      ,(select count(a.resource_id)
        from   pd_resource_task_alloc a
               left OUTER JOIN pd_resource_task b on (a.task_id=b.task_id)
        where  a.task_id=t.id
       ) as allocatedTask
      ,(select count(a.resource_id)
        from   pd_resource_task_alloc a
               left OUTER JOIN pd_resource_task b on (a.task_id=b.task_id)
        where  a.task_id=t.id
        and    b.task_status_id='2'
       ) as completedTask
      ,(select count(a.resource_id)
        from   pd_resource_task_alloc a
               left OUTER JOIN pd_resource_task b on (a.task_id=b.task_id)
        where  a.task_id=t.id
        and    b.task_status_id!='2'
       ) as pendingTask
      ,c.name as category
      ,sub.task_id
      ,t.name
      ,sub.bucket_date
      ,sum(sub.alloc_time) as s
from   (select rt.task_id
              ,rt.resource_id
              ,rt.project_id
              ,rta.sequence
              ,rta.alloc_time
              ,th.creation_date -- assuming creation_date is a DATE datatype?
              ,rt.start_date
              ,th.task_status_id
              ,rt.start_date as bucket_date
        from   resource_task rt
               join resource_task_alloc rta on (rt.task_id = rta.task_id
                                            and rt.resource_id = rta.resource_id
                                            and rt.project_id = rta.project_id)
               join task_history th on (rt.task_id = th.task_id)
        where  th.task_status_id >=2
        and    rta.alloc_time > 0
        and    rt.start_date is not null
       ) sub
       join pd_tool_user u on (sub.resource_id = u.id)
       join pd_task t on (sub.task_id = t.id)
       join pd_project p on (sub.project_id = p.id)
       join pd_category c on (t.category_id = c.id)
where  sub.start_date >= to_date('2011-11-01','YYYY-MM-DD') -- assuming start_date is a DATE datatype
and    sub.creation_date <= to_date('2011-11-31','YYYY-MM-DD') -- assuming creation_date is a DATE datatype
and    sub.project_id='355'
group by p.project
        ,u.username
        ,p.id
        ,u.name
        ,sub.task_id
        ,t.name
        ,c.name
        ,sub.bucket_date
order by u.username
        ,sub.bucket_date
        ,p.name
        ,c.name

Similar Messages

  • Clarification on using function in where clause of oracle sql query

    I have an issue in regarding function using where clause of sql query..
    We are facing performance issue while executing query, so in what ways to improve the performance of the query which i have posted below.
    select col ,case when my_function(parameter)
    from tab1 a ,tab2 b,tabl3 c
    where a.column1=b.column2
    and b.column3 =c.column6
    and my_function(parameter)>0
    Regards
    Dinesh
    Edited by: wild fire on May 18, 2012 4:15 PM

    Dinesh,
    remind that when you use a function in the where clause it normally will get started for each record in the table.
    So your answer is two-fold:
    1. make the function only start when needed by adding a function based index on the table (this will make inserts and updates slower)
    2. make the function faster by adding the DETERMINISTIC clause if possible. this will make Oracle "cache" the result of the function.
    Regards,
    Richard
    blog: http://blog.warp11.nl
    twitter: @rhjmartens
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Oracle Sql Query issue Running on Different DB Version

    Hello All,
    I have come into situation where we are pruning sql queries on different DB version of Oracle and have performance issue. Let me tell you in brief and i really appreciate for your prompt response as its very imperative stuff.
    I have a query which is running on a DB of version 7.3.4 and it takes around 30 mins where as the same query when run on 8i it takes 15sec., its a huge difference. I have run the statistics to analyze on 7.3 and its comparatively very high. Question here is, the sql query trys to select data from same schema table and 2 tables from another DB using DB link and 2 other tables from another DB using DB link.So,how can we optimize this stuff and achieve this run as same time as 8i DB in 7.3. Hope i am clear about my question, Eagerly waiting for your replies.
    Thanks in Advance.
    Message was edited by:
    Ram8

    Difficult to be sure without any more detailed information, but I suspect that O7 is in effect copying the remote tables to local temp space, then joining; 8i is factoring out a better query to send to the remote DBs, which does as much work as possible on the remote DB before shipping remaining rows back to local.
    You should be able to use EXPLAIN PLAN to identify what SQL is being shipped to the remote DB, If you can't (and it's been quite a while since I tried DB links or O7) then get the remote DBs to yourself, and set SQL_TRACE on for the remote instances. Execute the query and then examine the remote trace files, And don't forget to turn off the tracing when you're done.
    Of course it could just be that the CBO got better,,,
    HTH - if not, post your query and plans for the local db, and the remote queries.
    Regards Nigel

  • Oracle SQL Query from EXCEL 2007 with prompt

    Hello,
    I have many excel reports where I am pulling information from our Oracle 9 db through Excel using the following method:
    http://blog.mclaughlinsoftware.com/microsoft-excel/how-to-query-oracle-from-excel-2007/
    http://blog.mclaughlinsoftware.com/2009/11/30/sql-query-in-excel-2007/
    However, I am having trouble when I try the following query due to the prompt:
    SELECT
    IM.ITEM_GROUP,
    IM.ITEM,
    IM.DESCRIPTION
    FROM
    LAWSON.ITEMMAST IM
    WHERE
    IM.ITEM = '&ITEM';
    Does any one know how I can connect a prompt to an excel cell and then pass the query on to Oracle, or have a PL SQL prompt work from Excel?
    Thanks,
    Ben

    The 'prompt' as you call it is a sqlplus feature, so does not belong to the SQL language
    You would need to write a stored procedure returning a resultset.
    create or replace procedure foo(rc in out sys_refcursor, p_item) as
    begin
    open rc for
    'SELECT
    IM.ITEM_GROUP,
    IM.ITEM,
    IM.DESCRIPTION
    FROM
    LAWSON.ITEMMAST IM
    WHERE
    IM.ITEM = '||p_item;
    end;
    and call that using ODBC or asp.net
    Obviously this is profusely documented.
    Sybrand Bakker
    Senior Oracle DBA

  • Oracle SQL query for getting specific special characters from a table

    Hi all,
    This is my table
    Table Name- Table1
    S.no    Name
    1          aaaaaaaa
    2          a1234sgjghb
    3          a@3$%jkhkjn
    4          abcd-dfghjik
    5          bbvxzckvbzxcv&^%#
    6          ashgweqfg/gfjwgefj////
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    9           dfgfdgfd"uodf
    10         aaaa  bbbbz#$
    11         cccc dddd-/mnm
    The output has to be
    S.no    Name
    3          a@3$%jkhkjn
    5          bbvxzckvbzxcv&^%#
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    10         aaaa  bbbbz#$
    It has to return "Name" column which is having special characters,whereas some special chars like -, / ," and space are acceptable.
    The Oracle query has to print columns having special characters excluding -,/," and space
    Can anyone help me to get a SQL query for the above.
    Thanks in advance.

    You can achieve it in multiple ways. Here are few.
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where regexp_like(translate(name,'a-/" ','a'), '[^[:alnum:]]');
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where translate
    19         (
    20            lower(translate(name,'a-/" ','a'))
    21          , '.0123456789abcdefghijklmnopqrstuvwxyz'
    22          , '.'
    23         ) is not null;
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL>

  • Why does Oracle SQL query returning a date field without the time component

    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!

    hokim wrote:
    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!http://edstevensdba.wordpress.com/category/nls_date_format/

  • Convert Oracle SQL Query to SQLite Query

    Hi,
    I am new to SQLite and have requirement to write quries in SQLite format. As table structure is same in both the Oracle and SQLite database i have created queries in Oracle SQL. Now wanted to know is there any tool or package available which will convert my simple Oracle queries into SQLite format???
    Please guide..
    Regards,
    Priyanka

    with tree as (
    select
    level lev
    ,id
    ,parent_id
    ,sys_connect_by_path(id, '-') p
    from test_temp
    connect by
    parent_id = prior id
    start with parent_id is null
    select
    from tree t1
    where exists (
    select 1
    from tree t2
    where substr(t2.p, 1, length(t1.p)) = t1.p
      and regexp_count(t2.p, '-') = regexp_count(t1.p, '-') + 2
      -- if regexp_count is not available in your version or performs not well, below is an alternative
      -- and length(t2.p) - length(replace(t2.p, '-')) = length(t1.p) - length(replace(t1.p, '-')) + 2
    LEV
    ID
    PARENT_ID
    P
    1
    1
    -1
    2
    3
    1
    -1-3
    2
    5
    1
    -1-5
    1
    2
    -2
    2
    6
    2
    -2-6
    3
    14
    6
    -2-6-14

  • Oracle sql query execute in the apex

    hi:
    my requirement is, in region i have one text area item and query button.
    in this text area i am typing the any sql query and when i am pressing the query button it should display the query output report..
    pls give solution fast as soon as possible....
    Message was edited by:
    anbarasan

    Hi anbarasan,
    Maybe you can create a report of type "SQL query (PL/SQL Function returning query". Then in the region source, something like:
    DECLARE
    v_sql VARCHAR2 (4000);
    BEGIN
    v_sql := :PX_YOUR_ITEM;
    RETURN v_sql;
    END;
    Paulo Vale
    http://apex-notes.blogspot.com

  • SQL Query Assistance Required for Full Outer Join

    Hi,
    Lets say I have two tables, i.e:
    TAB_A (colA1, colA2, colA3, colA4)
    TAB_B (colB1, colB2, colB3, colB4) where colB2 is a FK to colA1
    I am after an SQL query that will cater for both the following two scenarios.
    Scenario 1:
    TAB_A has two rows of data, i.e
    (1, ABC100, 1, WG_A)
    (2, ABC100, 2, WG_B)
    TAB_B has one row of data, i.e
    (1, 1, EMP_222, 4)
    I use the following SQL:
    select a.*, b.*
    from tab_a a FULL OUTER JOIN tab_b b ON (a.colA1 = b.colB2)
    where a.colA2 = 'ABC100'
    This returns two rows:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    2, ABC100, 2, WG_B
    Now, what I actually would like my query to do is actually only return the row where a tab_b record exists, i.e, should only return one record:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    This I can achieve by using a RIGHT OUTER JOIN instead above, but this causes issue with my scenario 2, which is the following set-up
    Scenario 2:
    TAB_A has only one row of data this time, i.e
    (2, ABC100, 2, WG_B)
    TAB_B has no data at all this time
    This returns no rows but I actually now want this single record from tab_a returned.
    I basically require an SQL query that will cater for both the top 2 scenarios, i.e, if a tab_b record exists from the outer join then only return this record along with tab_a data. If a tab_b record doesn't exist, then only return the tab_a record.
    Hope the above makes sense.
    Thanks.

    Is it what you need (not very elegant) ?
    SQL> select * from t_outer;
            ID CODE
             1 100
             2 100
    SQL> select * from t_inner;
    no rows selected
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             1 100
             2 100
    SQL> insert into t_inner values(2);
    1 row created.
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             2 100                 2
    Rgds.

  • Sql query tuning required

    Dear Experts,
    I have a sql query which taking more than 2 hour of time ot execute.
    the explain plan is :
    PLAN_TABLE_OUTPUT
    Plan hash value: 2694368390
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 379 | 44561 (1)| 00:08:55 |
    | 1 | INLIST ITERATOR | | | | | |
    | 2 | TABLE ACCESS BY INDEX ROWID | OPS_CITY_MAST | 2 | 30 | 5 (0)| 00:00:01 |
    |* 3 | INDEX UNIQUE SCAN | OPS_CITY_MAST_IDX_01 | 2 | | 3 (0)| 00:00:01 |
    | 4 | TABLE ACCESS BY INDEX ROWID | OPS_BR_MAST | 1 | 16 | 2 (0)| 00:00:01 |
    |* 5 | INDEX UNIQUE SCAN | OPS_BR_MAST_IDX_01 | 1 | | 1 (0)| 00:00:01 |
    | 6 | TABLE ACCESS BY INDEX ROWID | OPS_CHG_GROUP_AMT | 1 | 15 | 4 (0)| 00:00:01 |
    |* 7 | INDEX UNIQUE SCAN | OPS_CHG_GROUP_AMT_IDX_02 | 1 | | 3 (0)| 00:00:01 |
    | 8 | TABLE ACCESS BY INDEX ROWID | OPS_CHG_GROUP_AMT | 1 | 15 | 4 (0)| 00:00:01 |
    |* 9 | INDEX UNIQUE SCAN | OPS_CHG_GROUP_AMT_IDX_02 | 1 | | 3 (0)| 00:00:01 |
    | 10 | TABLE ACCESS BY INDEX ROWID | OPS_CHG_GROUP_AMT | 1 | 15 | 4 (0)| 00:00:01 |
    |* 11 | INDEX UNIQUE SCAN | OPS_CHG_GROUP_AMT_IDX_02 | 1 | | 3 (0)| 00:00:01 |
    | 12 | TABLE ACCESS BY INDEX ROWID | OPS_CHG_GROUP_AMT | 1 | 15 | 4 (0)| 00:00:01 |
    |* 13 | INDEX UNIQUE SCAN | OPS_CHG_GROUP_AMT_IDX_02 | 1 | | 3 (0)| 00:00:01 |
    | 14 | TABLE ACCESS BY INDEX ROWID | OPS_CHG_GROUP_AMT | 1 | 15 | 4 (0)| 00:00:01 |
    |* 15 | INDEX UNIQUE SCAN | OPS_CHG_GROUP_AMT_IDX_02 | 1 | | 3 (0)| 00:00:01 |
    | 16 | TABLE ACCESS BY INDEX ROWID | OPS_CHG_GROUP_AMT | 1 | 15 | 4 (0)| 00:00:01 |
    |* 17 | INDEX UNIQUE SCAN | OPS_CHG_GROUP_AMT_IDX_02 | 1 | | 3 (0)| 00:00:01 |
    | 18 | SORT GROUP BY NOSORT | | 1 | 31 | 10 (0)| 00:00:01 |
    | 19 | NESTED LOOPS | | | | | |
    | 20 | NESTED LOOPS | | 2 | 62 | 10 (0)| 00:00:01 |
    | 21 | TABLE ACCESS BY INDEX ROWID | OPS_UULT_WB_DTLS | 2 | 24 | 6 (0)| 00:00:01 |
    |* 22 | INDEX RANGE SCAN | OPS_UULT_WB_DTLS_IDX_03 | 2 | | 3 (0)| 00:00:01 |
    |* 23 | INDEX UNIQUE SCAN | OPS_UPD_ULT_IDX_01 | 1 | | 1 (0)| 00:00:01 |
    |* 24 | TABLE ACCESS BY INDEX ROWID | OPS_UPD_ULT | 1 | 19 | 2 (0)| 00:00:01 |
    | 25 | NESTED LOOPS | | | | | |
    | 26 | NESTED LOOPS | | 1 | 379 | 44561 (1)| 00:08:55 |
    | 27 | NESTED LOOPS | | 1 | 360 | 44559 (1)| 00:08:55 |
    | 28 | NESTED LOOPS | | 1 | 333 | 44558 (1)| 00:08:55 |
    | 29 | NESTED LOOPS | | 1 | 312 | 44557 (1)| 00:08:55 |
    | 30 | NESTED LOOPS | | 1 | 302 | 44555 (1)| 00:08:55 |
    | 31 | NESTED LOOPS | | 1 | 281 | 44553 (1)| 00:08:55 |
    |* 32 | HASH JOIN | | 4383 | 1112K| 35779 (2)| 00:07:10 |
    |* 33 | HASH JOIN RIGHT OUTER | | 4383 | 1070K| 34631 (2)| 00:06:56 |
    | 34 | TABLE ACCESS FULL | OPS_CUST_CNTR | 7270 | 94510 | 68 (0)| 00:00:01 |
    |* 35 | HASH JOIN | | 4383 | 1014K| 34562 (2)| 00:06:55 |
    | 36 | NESTED LOOPS OUTER | | 4414 | 875K| 33135 (2)| 00:06:38 |
    |* 37 | HASH JOIN | | 4414 | 827K| 32963 (2)| 00:06:36 |
    | 38 | TABLE ACCESS FULL | OPS_ST_UN_MAST | 36 | 504 | 3 (0)| 00:00:01 |
    |* 39 | HASH JOIN | | 4414 | 767K| 32959 (2)| 00:06:36 |
    |* 40 | HASH JOIN | | 4414 | 543K| 28417 (2)| 00:05:41 |
    | 41 | NESTED LOOPS | | | | | |
    | 42 | NESTED LOOPS | | 4414 | 495K| 26483 (2)| 00:05:18 |
    |* 43 | HASH JOIN | | 4949 | 483K| 16641 (2)| 00:03:20 |
    |* 44 | TABLE ACCESS BY INDEX ROWID| OPS_WAYBL | 4423 | 367K| 2292 (1)| 00:00:28 |
    |* 45 | INDEX RANGE SCAN | OPS_WAYBL_IDX_11 | 5050 | | 16 (0)| 00:00:01 |
    | 46 | TABLE ACCESS FULL | OPS_PULTD_WB_DTLS | 4474K| 64M| 14298 (2)| 00:02:52 |
    |* 47 | INDEX UNIQUE SCAN | OPS_TS_RECONSILE_IDX_02 | 1 | | 1 (0)| 00:00:01 |
    |* 48 | TABLE ACCESS BY INDEX ROWID | OPS_TS_RECONSILE | 1 | 15 | 2 (0)| 00:00:01 |
    | 49 | TABLE ACCESS FULL | OPS_CC_CORCEE_ADDR | 998K| 10M| 1922 (2)| 00:00:24 |
    | 50 | TABLE ACCESS FULL | OPS_ADDR_MAST | 1006K| 49M| 4531 (1)| 00:00:55 |
    | 51 | TABLE ACCESS BY INDEX ROWID | OPS_WB_DOD_DTLS | 1 | 11 | 1 (0)| 00:00:01 |
    |* 52 | INDEX UNIQUE SCAN | OPS_WB_DOD_DTLS_IDX_02 | 1 | | 0 (0)| 00:00:01 |
    | 53 | TABLE ACCESS FULL | OPS_TRIP_SHT | 423K| 13M| 1422 (2)| 00:00:18 |
    | 54 | TABLE ACCESS FULL | OPS_PROV_LT_DLVRY | 446K| 4361K| 1142 (2)| 00:00:14 |
    | 55 | TABLE ACCESS BY INDEX ROWID | OPS_PLTD_WB_DTLS | 1 | 21 | 2 (0)| 00:00:01 |
    |* 56 | INDEX UNIQUE SCAN | OPS_PLTD_WB_DTLS_IDX_04 | 1 | | 1 (0)| 00:00:01 |
    | 57 | TABLE ACCESS BY INDEX ROWID | OPS_ULTD_WB_DTLS | 1 | 21 | 2 (0)| 00:00:01 |
    |* 58 | INDEX UNIQUE SCAN | OPS_ULTD_WB_DTLS_IDX_02 | 1 | | 1 (0)| 00:00:01 |
    |* 59 | TABLE ACCESS BY INDEX ROWID | OPS_UPD_LT_DLVRY | 1 | 10 | 2 (0)| 00:00:01 |
    |* 60 | INDEX UNIQUE SCAN | OPS_UPD_LT_DLVRY_IDX_01 | 1 | | 1 (0)| 00:00:01 |
    | 61 | TABLE ACCESS BY INDEX ROWID | OPS_TRPT_VHLS | 1 | 21 | 1 (0)| 00:00:01 |
    |* 62 | INDEX UNIQUE SCAN | OPS_TRPT_VHLS_IDX_01 | 1 | | 0 (0)| 00:00:01 |
    | 63 | TABLE ACCESS BY INDEX ROWID | PO_VENDORS | 1 | 27 | 1 (0)| 00:00:01 |
    |* 64 | INDEX UNIQUE SCAN | VENDOR_UNIQUE | 1 | | 0 (0)| 00:00:01 |
    |* 65 | INDEX UNIQUE SCAN | OPS_GATE_PASS_IDX_01 | 1 | | 1 (0)| 00:00:01 |
    |* 66 | TABLE ACCESS BY INDEX ROWID | OPS_GATE_PASS | 1 | 19 | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    3 - access("OCM"."ID"=:B1 OR "OCM"."ID"=:B2)
    5 - access("OBM"."ID"=:B1)
    7 - access("CGA"."DOC_TYPE"='WB' AND "CGA"."DOC_ID"=:B1 AND "CGA"."CHG_GROUP_ID"=6)
    9 - access("CGA"."DOC_TYPE"='WB' AND "CGA"."DOC_ID"=:B1 AND "CGA"."CHG_GROUP_ID"=7)
    11 - access("CGA"."DOC_TYPE"='GP' AND "CGA"."DOC_ID"=:B1 AND "CGA"."CHG_GROUP_ID"=15)
    13 - access("CGA"."DOC_TYPE"='GP' AND "CGA"."DOC_ID"=:B1 AND "CGA"."CHG_GROUP_ID"=16)
    15 - access("CGA"."DOC_TYPE"='GP' AND "CGA"."DOC_ID"=:B1 AND "CGA"."CHG_GROUP_ID"=17)
    17 - access("CGA"."DOC_TYPE"='GP' AND "CGA"."DOC_ID"=:B1 AND "CGA"."CHG_GROUP_ID"=23)
    22 - access("DT"."WAYBL_ID"=:B1)
    23 - access("ULT"."ID"="DT"."UPD_ULT_ID")
    24 - filter("ULT"."FROM_BR_MAST_ID"=:B1)
    32 - access("OPL"."ID"="TS"."PROV_LT_DLVRY_ID")
    33 - access("CNTR"."ID"(+)="SYS_ALIAS_10"."CUST_CNTR_ID")
    35 - access("TSREC"."TRIP_SHT_ID"="TS"."ID")
    37 - access("ST"."ID"="AD"."ST_UN_MAST_ID")
    39 - access("AD"."ID"="CCADD"."ADDR_MAST_ID")
    40 - access("CCADD"."ID"="SYS_ALIAS_10"."CC_CEE_ADDR_ID")
    43 - access("SYS_ALIAS_10"."ID"="DTL"."WAYBL_ID")
    44 - filter("SYS_ALIAS_10"."GL_TRFD" IS NULL OR "SYS_ALIAS_10"."GL_TRFD"='Y')
    45 - access(TRUNC(INTERNAL_FUNCTION("FIRST_DLVRY_DT"))=TO_DATE(' 2011-08-15 00:00:00', 'syyyy-mm-dd
    hh24:mi:ss'))
    47 - access("DTL"."ID"="TSREC"."PULTD_WB_DTLS_ID")
    48 - filter("TSREC"."STATUS_LID"=157)
    52 - access("SYS_ALIAS_10"."ID"="OWD"."WAYBL_ID"(+))
    56 - access("LTDTL"."PROV_LT_DLVRY_ID"="OPL"."ID" AND "LTDTL"."WAYBL_ID"="DTL"."WAYBL_ID")
    58 - access("ULTDTL"."PLTD_WB_DTLS_ID"="LTDTL"."ID")
    59 - filter("UPLT"."PROV_LT_DLVRY_ID"="OPL"."ID")
    60 - access("ULTDTL"."UPD_LT_DLVRY_ID"="UPLT"."ID")
    62 - access("OTV"."ID"="OPL"."TRPT_VHLS_ID")
    64 - access("PO"."VENDOR_ID"="OTV"."VENDOR_ID")
    65 - access("SYS_ALIAS_9"."ID"="ULTDTL"."GATE_PASS_ID")
    66 - filter("SYS_ALIAS_9"."GL_TRFD" IS NULL OR "SYS_ALIAS_9"."GL_TRFD"='Y')
    so, please help me.
    Regards,
    Viveka Nand
    Edited by: 891502 on Oct 14, 2011 4:39 AM

    891502 wrote:
    now am putted in the correct format,In the link it tells you to provide the query. Which you have not done.
    It tells you how to format the plan. Which you have not done.
    It tells you to provide database version and optimizer parameters. Which you have not done.
    It tells you to provide autotrace statistics and trace output. Which you have not done.
    So in what way is this format correct ?
    so, please give me the way to resolved it.With the information you have provided we can say with certainty that if you write your query this way it will be fast.
    select null from dual;

  • Handling hierarchy in oracle sql query

    I have two tables:
    The first contains COMPANY_ID and CATEGORY_ID
    The second contains CATEGORY_ID and PARENT_CATEGORY_ID
    I need to return a list containing COMPANY_ID and CATEGORY_ID. The entries, however, must come not only from the first table, but also include all the descendants listed in the second table.
    So for example (and please read the example carefully) - let’s say in the first table I have one row:
    COMPANY_ID | CATEGORY_ID
    1000 | 1
    In the second table, I have three rows:
    CATEGORY_ID | PARENT_CATEGORY_ID
    1 | null
    2 | 1
    3 | 2
    4 | null
    I want to have the following rows as a result:
    COMPANY_ID | CATEGORY_ID
    1000 | 1
    1000 | 2
    1000 | 3
    How can I do this in oracle 10 in a single SQL statement ?

    Hi,
    Welcome to the forum!
    Whenver you have a question, post your sample data in a form that people can use.
    CREATE TABLE and INSERT statements are great:
    CREATE TABLE  first
    (       company_id     NUMBER (4)
    ,     category_id     NUMBER (4)
    INSERT INTO first (company_id, category_id) VALUES (1000,   1);CREATE TABLE AS is good, too:
    CREATE TABLE  second
    AS
    SELECT     1 AS category_id, NULL AS parent_category_id     FROM dual     UNION ALL
    SELECT     2,               1                          FROM dual     UNION ALL
    SELECT     3,               2                          FROM dual     UNION ALL
    SELECT     4,               NULL                    FROM dual;Without that, people can't test their ideas, and are often unsure about your data.
    You should also say what version of Oracle you're using. That's especially important with CONNECT BY queries. Every version since Oracle 7 has had significant improvements in how to do CONNECT BY queries. The query below works in Oracle 10 (and up).
    For hierarchies and trees, use CONNECT BY
    When you have to join tables and use CONNECT BY, it's usually more efficient to do one in a sub-query, and the other in another query.
    In the example below, we're doing the CONNECT BY in sub-query cbq, and the join in the main query.
    WITH     cbq     AS
         SELECT     category_id
         ,     CONNECT_BY_ROOT category_id     AS root_category_id
         FROM     second
         START WITH     parent_category_id     IS NULL
               AND     category_id          IN ( SELECT  category_id          -- Maybe; see note below
                                             FROM    first
         CONNECT BY     parent_category_id     = PRIOR category_id
    SELECT  first.company_id
    ,     cbq.category_id
    FROM     first
    JOIN     cbq     ON     first.category_id     = cbq.root_category_id
    ;The 2nd condition in the START WITH clause won't change the results any; any rows that are excluded by that condition would also be excluded by the join condition. There can be a big differenece in performance, however. Try the query both ways, and use the 2nd condition if it helps.
    Edited by: Frank Kulash on Feb 3, 2010 3:46 PM

  • How to tune a oracle sql query to make it run faster ...

    Hi Guys,
    I am very new to this tuning of sql queries. It is taking a lot of time to run a query and give the output. I have a tool called TOAD[ Tool for oracle application development ] and i ran a query in that tool. Its showing that the query is taking 7sec to get its output. I donno the exact procedure what to follow in order to tune that query. What are these actually like : explain plan, sqltrace, tkprof and how to use these to tune the query. I want my query to run faster like in msec.
    Help Appreciated.
    Thanks

    http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm
    http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm#1018

  • Loading an Oracle SQL query into an MSSQL table

    I have a select query on an Oracle table. I want to load this data into an MSSQL table.
    Problem is that I cannot create an interim table on the Oracle database (lack of privelages)
    Is there a way to load an Oracle query into the MSSQL table without an interim table?
    Many thanks
    Z

    Yes,
    1) Create an ODI procedure
    2) Create a step inside
    3) at source tab put the oracle query
    4) at target tab put the sql insert code
    Refer to the oracle returned values like "#column_name_from_oracle_query"
    Make sense?
    Cezar Santos
    [www.odiexperts.com]

  • Convert Oracle SQL query to single column output

    Hello All,
    I need to build the query to have multiple columns in a single column with multiple rows.
    select a.customer_trx_id,a.previous_customer_trx_id
    from ra_customer_trx_all a
    where a.customer_trx_id = :customer_trx_id
    here, a.customer_trx_id and a.previous_customer_trx_id are in two columns. I need to bring them into a single column.
    Say: the above output is
    a.customer_trx_id a.previous_customer_trx_id
    123456 87654
    Need to have single column
    As
    123456
    87654
    Please do the needful.
    Thanks,
    Abdul

    Hi,
    Post your question in [SQL and PL/SQL|http://forums.oracle.com/forums/forum.jspa?forumID=75] forum, you would probably get a better/faster response.
    Regards,
    Hussein

  • Oracle sql query works

    Can any body tell , how the sql select statement will works ? how it will come across the 3 phases 1.pharse 2.execute and 3. fetch
    what is the parameter in oracle 9i and 10g for compress the dumpfile in export and import?

    Hi,
    Welcome to forums.. !!
    Can any body tell , how the sql select statement will works ? how it will come across the 3 phases 1.pharse 2.execute and 3. fetch Try to refer to : How the select Query Works
    Oracle documentation explains every thing, just spend some time.
    what is the parameter in oracle 9i and 10g for compress the dumpfile in export and import?You must check the Oracle documentation. From high level the compress parameter works different for both versions while allocations the extents.
    - Pavan Kumar N

Maybe you are looking for