Hi need help in writing this query

A table has three columns - id (primary key), categoryID (numeric) and
amount (numeric). The goal is to provide a query that would show categoryID
and sum of amounts within that category where categoryID is an odd number
and sum of amounts is greater than 100,000

select categoryid,sum(amount) from table where mod(categoryid,2)=1
group by categoryid
having sum(amount) > 100000
Regards,
Yuri
[http://it.toolbox.com/blogs/living-happy-oracle]

Similar Messages

  • Need help in writing the query

    The initial data is as follows:
    ID PARENT_ID
    =============
    1 NULL
    2 NULL
    3 2
    4 6
    5 3
    6 7
    7 4
    8 NULL
    but output is as follows in such way that Parent_Id should be displayed in ID place
    ID PARENT_ID
    =============
    1 NULL
    2 NULL
    3 2
    8 NULL
    6 8
    4 6
    5 3
    7 4
    Can any one help how resolve this query?
    Thanks in advance

    Your output is inconsistent with initial data :) But
    select * from t start with parent_id is null connect by parent_id = prior id;

  • Need help with writing a query with dynamic FROM clause

    Hi Folks,
    I need help with an query that should generate the "FROM" clause dynamically.
    My main query is as follows
    select DT_SKEY, count(*)
    from *???*
    where DT_SKEY between 20110601 and 20110719
    group by DT_SKEY
    having count(*) = 0
    order by 1; The "from" clause of the above query should be generated as below
    select 'Schema_Name'||'.'||TABLE_NAME
    from dba_tables
    where OWNER = 'Schema_Name'Simply sticking the later query in the first query does not work.
    Any pointers will be appreciated.
    Thanks
    rogers42

    Hi,
    rogers42 wrote:
    Hi Folks,
    I need help with an query that should generate the "FROM" clause dynamically.
    My main query is as follows
    select DT_SKEY, count(*)
    from *???*
    where DT_SKEY between 20110601 and 20110719
    group by DT_SKEY
    having count(*) = 0
    order by 1; The "from" clause of the above query should be generated as below
    select 'Schema_Name'||'.'||TABLE_NAME
    from dba_tables
    where OWNER = 'Schema_Name'
    Remember that anything inside quotes is case-sensitive. Is the owner really "Schema_Name" with a capital S and a capital N, and 8 lower-case letters?
    Simply sticking the later query in the first query does not work.Right; the table name must be given when you compile the query. It's not an expression that you can generate in the query itself.
    Any pointers will be appreciated.In SQL*Plus, you can do something like the query bleow.
    Say you want to count the rows in scott.emp, but you're not certain that the name is emp; it could be emp_2011 or emp_august, or anything else that starts with e. (And the name could change every day, so you can't just look it up now and hard-code it in a query that you want to run in the future.)
    Typically, how dynamic SQL works is that some code (such as a preliminary query) gets some of the information you need to write the query first, and you use that information in a SQL statement that is compiled and run after that. For example:
    -- Preliminary Query:
    COLUMN     my_table_name_col     NEW_VALUE my_table_name
    SELECT     table_name     AS my_table_name_col
    FROM     all_tables
    WHERE     owner          = 'SCOTT'
    AND     table_name     LIKE 'E%';
    -- Main Query:
    SELECT     COUNT (*)     AS cnt
    FROM     scott.&my_table_name
    ;This assumes that the preliminary query will find exactly one row; that is, it assumes that SCOTT has exactly one table whose name starts with E. Could you have 0 tables in the schema, or more than 1? If so, what results would you want? Give a concrete example, preferably suing commonly available tables (like those in the SCOTT schema) so that the poepl who want to help you can re-create the problem and test their ideas.
    Edited by: Frank Kulash on Aug 11, 2011 2:30 PM

  • Need help in tune this query.

    Hi All,
    The below query is taking nearly one hour to give the output.
      2  select sku.VK_UNIT
      3       , sku.MODEL
      4       , sku.DESCRIPTION
      5       , slt.GEO
      6       , slt.LEAD_TIME
      7       , slt.REV_LEAD_TIME
      8       , aud.LEAD_TIME        as PREV_LEAD_TIME_GEO
      9       , aud.REV_LEAD_TIME    as PREV_REV_LEAD_TIME_GEO
    10       , slt.COUNTDOWN
    11       , aud.CREATION_DATE    as EDD_CREATION_DATE_GEO
    12       , aud.CREATED_BY       as EDD_CREATED_BY_GEO
    13    from LTC_GLOBAL.LTC_SKU sku
    14       , LTC_GLOBAL.LTC_SKU_LEAD_TIME slt
    15       , (select VK_UNIT
    16               , MODEL
    17               , substr(ACTION_TYPE, 9) as GEO
    18               , max(case when substr(ACTION_TYPE, 1, 8) = 'SKU EDD ' then ACTION_VALUE  else null end) as LEAD_TIME
    19               , max(case when substr(ACTION_TYPE, 1, 8) = 'SKU EDD ' then CREATION_DATE else null end) as CREATION_DATE
    20               , max(case when substr(ACTION_TYPE, 1, 8) = 'SKU EDD ' then CREATED_BY    else null end) as CREATED_BY
    21               , max(case when substr(ACTION_TYPE, 1, 8) = 'SKU RDD ' then ACTION_VALUE  else null end) as REV_LEAD_TIME
    22               , max(case when substr(ACTION_TYPE, 1, 8) = 'SKU RDD ' then CREATION_DATE else null end) as REV_CREATION_DATE
    23               , max(case when substr(ACTION_TYPE, 1, 8) = 'SKU RDD ' then CREATED_BY    else null end) as REV_CREATED_BY
    24            from (select VK_UNIT
    25                       , MODEL
    26                       , ACTION_TYPE
    27                       , ACTION_VALUE
    28                       , CREATION_DATE
    29                       , CREATED_BY
    30                       , PREV_ACTION_VALUE
    31                       , PREV_CREATION_DATE
    32                       , PREV_CREATED_BY
    33                    from (select
    34                                 NOTE         as VK_UNIT
    35                               , NOTE2        as MODEL
    36                               , ACTION_TYPE
    37                               , ACTION_VALUE
    38                               , CREATION_DATE
    39                               , CREATED_BY
    40                               , row_number()        over(partition by NOTE, NOTE2, ACTION_TYPE order by CREATION_DATE desc) as DEPTH
    41                               , lead(CREATION_DATE) over(partition by NOTE, NOTE2, ACTION_TYPE order by CREATION_DATE desc) as PREV_CREATION_DATE
    42                               , lead(CREATED_BY   ) over(partition by NOTE, NOTE2, ACTION_TYPE order by CREATION_DATE desc) as PREV_CREATED_BY
    43                               , lead(ACTION_VALUE ) over(partition by NOTE, NOTE2, ACTION_TYPE order by CREATION_DATE desc) as PREV_ACTION_VALUE
    44                            from LTC_GLOBAL.LTC_AUDIT
    45                           where NOTE is not null
    46                             and NOTE2 is not null
    47                             and ACTION_TYPE is not null
    48                         )
    49                   where DEPTH = 2
    50                     and substr(ACTION_TYPE, 1, 8) in ('SKU EDD ', 'SKU RDD ')
    51                 )
    52           group by VK_UNIT, MODEL, substr(ACTION_TYPE, 9)
    53         ) aud
    54  where slt.VK_UNIT = sku.VK_UNIT
    55     and slt.MODEL   = sku.MODEL
    56     and slt.CLASS   = sku.CLASS
    57     and nvl(slt.LEAD_TIME, slt.REV_LEAD_TIME) is not null
    58     and aud.VK_UNIT (+)= slt.VK_UNIT
    59     and aud.MODEL   (+)= slt.MODEL
    60     and aud.GEO     (+)= slt.GEO;
    PLAN_TABLE_OUTPUT
    Plan hash value: 2687821083
    | Id  | Operation                   | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time  |
    |   0 | SELECT STATEMENT            |                   |   539K|   902M|       |  1005K  (1)| 03:21:05 |
    |*  1 |  HASH JOIN OUTER            |                   |   539K|   902M|    62M|  1005K  (1)| 03:21:05 |
    |*  2 |   HASH JOIN                 |                   |   539K|    56M|    27M| 66402   (1)| 00:13:17 |
    |*  3 |    TABLE ACCESS FULL        | LTC_SKU_LEAD_TIME |   559K|    20M|       | 23201   (2)| 00:04:39 |
    |   4 |    TABLE ACCESS FULL        | LTC_SKU_UNIT      |  5726K|   382M|       | 19570   (1)| 00:03:55 |
    |   5 |   VIEW                      |                   |  4157K|  6522M|       |   610K  (2)| 02:02:02 |
    PLAN_TABLE_OUTPUT
    |   6 |    HASH GROUP BY            |                   |  4157K|   229M|   303M|   610K  (2)| 02:02:02 |
    |*  7 |     VIEW                    |                   |  4157K|   229M|       |   551K  (2)| 01:50:21 |
    |*  8 |      WINDOW SORT PUSHED RANK|                   |  4157K|   229M|   303M|   551K  (2)| 01:50:21 |
    |*  9 |       TABLE ACCESS FULL     | LTC_AUDIT         |  4157K|   229M|       |   493K  (2)| 01:38:41 |
    Predicate Information (identified by operation id):
       1 - access("AUD"."VK_UNIT"(+)="SLT"."VK_UNIT" AND "AUD"."MODEL"(+)="SLT"."MODEL" AND
                  "AUD"."GEO"(+)="SLT"."GEO")
    PLAN_TABLE_OUTPUT
       2 - access("SLT"."VK_UNIT"="UNIT"."VK_UNIT" AND "SLT"."MODEL"="UNIT"."MODEL" AND
                  "SLT"."CLASS"="UNIT"."CLASS")
       3 - filter(NVL("SLT"."LEAD_TIME","SLT"."REV_LEAD_TIME") IS NOT NULL)
       7 - filter("DEPTH"=2)
       8 - filter(ROW_NUMBER() OVER ( PARTITION BY "NOTE","NOTE2","ACTION_TYPE" ORDER BY
                  INTERNAL_FUNCTION("CREATION_DATE") DESC )<=2)
       9 - filter((SUBSTR("ACTION_TYPE",1,8)='SKU EDD ' OR SUBSTR("ACTION_TYPE",1,8)='SKU RDD ') AND
                  "NOTE2" IS NOT NULL AND "ACTION_TYPE" IS NOT NULL)
    30 rows selected.
    SELECT COUNT(*) FROM LTC_GLOBAL.LTC_SKU--5012335
    SELECT COUNT(*) FROM  LTC_GLOBAL.LTC_SKU_LEAD_TIME--8060956
    SELECT COUNT(*) FROM  LTC_GLOBAL.LTC_AUDIT--58309887
    CREATE UNIQUE INDEX LTC_GLOBAL.LTC_SKU_LEAD_TIME_PK ON LTC_GLOBAL.LTC_SKU_LEAD_TIME(VK_UNIT, MODEL, CLASS, GEO)
    CREATE INDEX LTC_GLOBAL.LTC_AUDIT_LEAD_TIME ON LTC_GLOBAL.LTC_AUDIT(ACTION_TYPE)
    CREATE INDEX LTC_GLOBAL.LTC_AUDIT_LEAD_TIME_DOM ON LTC_GLOBAL.LTC_AUDIT(NOTE, NOTE2, ACTION_TYPE)
    CREATE INDEX LTC_GLOBAL.LTC_AUDIT_LEAD_TIME_DOM1 ON LTC_GLOBAL.LTC_AUDIT("CREATION_DATE" DESC)
    Please help me.
    Thanks in advance.

    Thanks for your response.
    Sorry for violating formatting. Since I am not aware of the format options in new environment.
    I have created functional based index on SUBSTR(ACTION_TYPE, 1, 8).
    The cost got reduced some what.But still the query is taking 40 minutes.
    The following predicate it is returning 58296618 rows.
    NOTE is not null  
    and NOTE2 is not null 
    and ACTION_TYPE is not null 
    LTC_SKU_UNIT is a view.
    The following query is used for creating this view.
       SELECT   unit.VK_UNIT,
                unit.MODEL,
                unit.CLASS,
                unit.LOB,
                unit.LAST_UPDATE_DATE,
                unit.DESCRIPTION
         FROM   LTC_GLOBAL.LTC_SKU_UNIT unit;
    The following indexes are created on the LTC_GLOBAL.LTC_SKU_UNIT table.
    CREATE INDEX LTC_GLOBAL.LTC_SKU_UNIT_IDX_CLASS ON LTC_GLOBAL.LTC_SKU_UNIT(CLASS)
    CREATE INDEX LTC_GLOBAL.LTC_SKU_UNIT_IDX_MODEL ON LTC_GLOBAL.LTC_SKU_UNIT(MODEL)
    CREATE INDEX LTC_GLOBAL.LTC_SKU_UNIT_IDX_UPDATE_DATE ON LTC_GLOBAL.LTC_SKU_UNIT(LAST_UPDATE_DATE)
    CREATE UNIQUE INDEX LTC_GLOBAL.LTC_SKU_UNIT_PK ON LTC_GLOBAL.LTC_SKU_UNIT(VK_UNIT, MODEL, CLASS)
    Is there any way to rewrite the query to improve the performance. Any suggestions to improve the performance.
    Please help me.
    Thanks in advance.

  • solved need help in tuning this Query

    hi frs,
    i have created a query like this
    pls help
    Regards
    Rajesh
    Message was edited by:
    Rajesh.mani
    Message was edited by:
    Rajesh.mani

    Code and explain plan should be between [pre] and [/pre] or [code] and [/code] tags like this.
    [pre]Code[/pre]An now explain plan
    [code]Execution plan
    [/code]
    Cheers
    Sarma.

  • Help on writing this query.

    Hi Folks,
    I'm trying to write a query to retrive the following information regarding snapshots. I tried lot of ways and couldn't get the solutions so seeking your help...
    Can you send me a query that will give me all this information.
    db name of snapshot site
    snapshot name and their base table
    refresh type (if it is fast, please list he snapshot log used)
    refresh group which snapshot belongs to
    dbms_job number which perform the refresh, job current status
    refresh frequency
    last refresh time
    thanks
    Karthik

    If you tried a lot of ways ... post your work and show us what you have done.
    What you are being asked to do is query data dictionary views. Do you know which ones?
    SELECT view_name
    FROM all_views
    WHERE view_name LIKE '%<you fill this in>%';That is all the hints you get until you show your work.

  • Need help in writing inline query or subquery

    Hi All,
    I have 4 select statements like below ,
    1>Select customer_number, customer_name,customer_address1
    FROM ABC
    WHERE Site_use_code='BILL_TO'
    2>Select customer_number, customer_name,customer_address1
    FROM ABC
    WHERE Site_use_code='SHIP_TO'
    3>Select customer_number, customer_name,customer_address1
    FROM ABC
    WHERE Site_use_code='SOLD_TO'
    I need to write all these 3 in single select statement in such a way that if any select statement doesnot return any data it should execute the other select statements means it should not fail.
    for each column of the select statment i can write separate select statements in that way it should work but the query should be very big.
    So please help me on thsi.
    Thanks

    Example of my solution:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (
      2    select 1 as customer_number, 'Fred' as customer_name, 'address1' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      3    select 1 as customer_number, 'Fred' as customer_name, 'address1' as customer_address1, 'SHIP_TO' as site_use_code from dual union all
      4    select 2 as customer_number, 'Bob' as customer_name, 'address2' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      5    select 3 as customer_number, 'George' as customer_name, 'address3' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      6    select 3 as customer_number, 'George' as customer_name, 'address3' as customer_address1, 'SHIP_TO' as site_use_code from dual union all
      7    select 3 as customer_number, 'George' as customer_name, 'address3' as customer_address1, 'SOLD_TO' as site_use_code from dual union all
      8    select 4 as customer_number, 'Tim' as customer_name, 'address4' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      9    select 5 as customer_number, 'Sam' as customer_name, 'address5' as customer_address1, 'BILL_TO' as site_use_code from dual
    10  )
    11  --
    12  -- END OF TEST DATA
    13  --
    14  select customer_number
    15        ,customer_name
    16        ,customer_address1
    17        ,site_use_code
    18  from (
    19        select customer_number
    20              ,customer_name
    21              ,customer_address1
    22              ,site_use_code
    23              ,row_number() over (partition by customer_number order by decode(Site_use_code,'BILL_TO',1,'SHIP_TO',2,3) desc) as rn
    24        FROM t
    25        WHERE Site_use_code IN ('BILL_TO','SHIP_TO','SOLD_TO')
    26       )
    27* where rn = 1
    SQL> /
    CUSTOMER_NUMBER CUSTOM CUSTOMER SITE_US
                  1 Fred   address1 SHIP_TO
                  2 Bob    address2 BILL_TO
                  3 George address3 SOLD_TO
                  4 Tim    address4 BILL_TO
                  5 Sam    address5 BILL_TO
    SQL>Or alternative...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (
      2    select 1 as customer_number, 'Fred' as customer_name, 'address1' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      3    select 1 as customer_number, 'Fred' as customer_name, 'address1' as customer_address1, 'SHIP_TO' as site_use_code from dual union all
      4    select 2 as customer_number, 'Bob' as customer_name, 'address2' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      5    select 3 as customer_number, 'George' as customer_name, 'address3' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      6    select 3 as customer_number, 'George' as customer_name, 'address3' as customer_address1, 'SHIP_TO' as site_use_code from dual union all
      7    select 3 as customer_number, 'George' as customer_name, 'address3' as customer_address1, 'SOLD_TO' as site_use_code from dual union all
      8    select 4 as customer_number, 'Tim' as customer_name, 'address4' as customer_address1, 'BILL_TO' as site_use_code from dual union all
      9    select 5 as customer_number, 'Sam' as customer_name, 'address5' as customer_address1, 'BILL_TO' as site_use_code from dual
    10  )
    11  --
    12  -- END OF TEST DATA
    13  --
    14  select distinct
    15         customer_number
    16        ,customer_name
    17        ,customer_address1
    18        ,first_value(site_use_code) over (partition by customer_number order by decode(Site_use_code,'BILL_TO',1,'SHIP_TO',2,3) desc) as site_use_code
    19  FROM t
    20  WHERE Site_use_code IN ('BILL_TO','SHIP_TO','SOLD_TO')
    21* order by customer_number
    SQL> /
    CUSTOMER_NUMBER CUSTOM CUSTOMER SITE_US
                  1 Fred   address1 SHIP_TO
                  2 Bob    address2 BILL_TO
                  3 George address3 SOLD_TO
                  4 Tim    address4 BILL_TO
                  5 Sam    address5 BILL_TO

  • Need help in writing a query

    Hi,
    I have a table with two columns as follows
    child parent
    mom grandma
    daughter mom
    How can I write a single query so that the result will be daughter,mom,grandma?
    Thanks
    Ravi.

    Responses to these postings will help:
    pivot the column names
    PIVOT in oracle.
    Re: Pivot Query

  • Need help in writing SQL query

    Hi,
    I have a rquirement where I need to convert columns into records.
    Table1:
    (note: I have around 150 columns i.e period1 to period150)
    unit startdate Period1 period2 period3 period4 period5
    A 1/1/2011 100 200 300 400 500
    Now I need data in below format
    UNIT startdate period
    A 1/1/2011 100
    A 1/1/2011 200
    A 1/1/2011 300
    A 1/1/2011 500
    Please suggest me...
    Thanks.

    With UNPIVOT you can "name" each of your rows using as.
    One trick is to "name" the rows to a number - then you can add that number of weeks to your start date - like this:
    with t as (
       select 'A' unit, DATE '2011-01-01' startdate, 100 period1, 200 period2 ,300 period3, 400 period4 ,500 period5 from dual
    select
    unit,
    startdate + numtodsinterval(week*7,'day') startdate,
    qty
    from t
    unpivot(
       qty for week in (
          period1 as 0,
          period2 as 1,
          period3 as 2,
          period4 as 3,
          period5 as 4
    ;Theoretically the above should work - but somehow I get a NULL date on my 11.1 instance? And I don't have another version to test with, alas.
    But try it and see if it works on your instance ;-)

  • Need Help in tuning this query

    select CO_PROFILE.CO_NO AS "UEN No.",
    CO_PROFILE.CO_NAME AS "Entity Name",
    DECODE(CO_PROFILE.CO_TYPE,'A1','PUBLIC COMPANY LIMITED BY SHARES',
    'A3','COMPANY LIMITED BY GUARANTEE',
    'A4','UNLIMITED PUBLIC COMPANY',
    'B1','LIMITED PRIVATE COMPANY',
    'B2','LIMITED EXEMPT PRIVATE COMPANY',
    'B3','UNLIMITED PRIVATE COMPANY',
    'B4','UNLIMITED EXEMPT PRIVATE COMPANY',
    'F1','FOREIGN COMPANY REGISTERED IN SINGAPORE') AS "Entity Type",
    M_STATUS.STATUS_DESC AS "Entity Status",
    PAYMENT_DETAIL.SERVICE_CODE AS "Service Code",
    PAYMENT_DETAIL.PAYMENT_CODE AS "Payment Code",
    CO_TRANS_MAST.CO_TRANS_ID AS "Transaction Type",
    M_PAYMENT_CODE.PAYMENT_DESC AS "Payment Description",
    M_PAYMENT_CODE.REVENUE_CODE AS "Revenue Account",
    CO_TRANS_MAST.NUM AS "Number Of Transactions",
    PAY_NEW.UNIT_AMT AS "Revenue Amount1",
    PAY_NEW.FILING_AMT AS "Revenue Amount2",
    PAYMENT_DETAIL.UNIT_FEE AS "Unit Cost"
    from CO_PROFILE,
    M_STATUS,
    PAYMENT_DETAIL,
    CO_TRANS_MASTER,
    (Select COUNT(CO_NO) AS "NUM",CO_TRANS_ID,CO_NO
    from CO_TRANS_MASTER
    group by CO_NO,CO_TRANS_ID
    )CO_TRANS_MAST,
    (Select Sum(UNIT_FEE) AS UNIT_AMT,
      SUM(FILING_FEE) AS FILING_AMT,
       TRANS_NO AS TRANS_NO
      from
      PAYMENT_DETAIL
      group by
      TRANS_NO)
    PAY_NEW,
    M_PAYMENT_CODE
    where rownum=1
    and CO_PROFILE.CO_STATUS=M_STATUS.STATUS_CODE
    and M_STATUS.TRANS_ID='COMP'
    and CO_TRANS_MASTER.CO_TRANS_ID=CO_TRANS_MAST.CO_TRANS_ID
    and CO_TRANS_MASTER.CO_NO=CO_TRANS_MAST.CO_NO
    and PAYMENT_DETAIL.TRANS_NO=CO_TRANS_MASTER.CO_TRANS_NO
    and PAY_NEW.TRANS_NO=PAYMENT_DETAIL.TRANS_NO
    and CO_TRANS_MAST.CO_NO= CO_PROFILE.CO_NO
    and M_PAYMENT_CODE.PAYMENT_CODE=PAYMENT_DETAIL.PAYMENT_CODE

    Something seems wrong to me with the logical structure of the select.
    1) You only get 1 row of output
    but you
    2) build sums for each trans_no
    3) You join the table co_trans_master but at the same time you count over that one. Might be ok to do so, but it seems to be double the work.
    Suggestion.
    a) Build a select that joins the payment detail table. Then group this select and build the sums.
    b) Add the count for the number of transactions to the select clause instead of and extra inline view in the from clause. Maybe as an analytical function if possible.

  • Need helping in writing query for finding percentage of duration

    Can any one please help in writing query for this.
    The table is like this :-
    ID     Region     Month     Duration
    I1 R1     Jan     80
    I2     R2     Jan     70
    I3     R1     Jan     70
    I4     R3     Jan     40
    I5     R1     Feb     80
    I6     R2     Feb     30
    I7     R3     Mar     100
    I want to write a query to find
    % of duration for each and every region against each and every month.
    Please help in solving this query. I am in urgent need of this.
    Thanks in advance.

    I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
    Nicolas.

  • Help in writing a query!

    Dear All,
    My database is 11gR2 on Linux.
    I am struck in writing a difficult query, need help from your guys.
    I have a table, an application is controlling the columns of this table. Columns are added by the application.
    This is the structure of the table:
    create table imran_test(
    2 username varchar2(100),
    3 layer1 number(1),
    4 layer2 number(2),
    5 layer3 number(2));
    -- where layer1, layer2, layer3.... are increased up to layer 22 and could be increased more...
    Now each username will have 1 in any one of the layer, and all other layers will have 0
    Like if I consider the above table this could be the sample data:
    imran 1 0 0
    hafeez 0 1 0
    james 0 0 1
    Now the result my query should return is:
    select username, <column name where value is 1> and value of it, as per sample data, this should be return by the query:
    imran layer1 1
    hafeez layer2 1
    james layer 3 1
    Note: Please remember the columns are not fixed, they are added/altered by application.
    Regards,
    Imran

    The table design is incorrect as it is not in 3NF and has a repeating group
    You should correct the 'design' first or turn the layer... columns in a VARRAY.
    Also my feeling is you should change your subject line 'Help in writing a query!' in 'Write my query' as that is what you actually ask, and leave out the exclamation mark.
    Basically you dump everything in this forum, and being a bit less demanding might suit you better.
    Also you still act rude by not marking your questions as answered.
    Change that
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 1-apr-2012 12:09

  • Need help on a sql query

    Hi Friends,
    I am trying to load Employees and their Assignments using APIs.
    I have various columns in my staging table like Last Name, First Name, etc., but I need help in writing query in the cursor especially for columns Emp Number and Supervisor Number.
    I have data as below
    Emp_Number     Supervisor_Number
    GE0002               GE0064
    GE0064               EG0009
    EG0009               EG0001
    100009                EG0001
    EG0001               TU0001
    Cursor I write will process the data in the same order as above, but here the problem is...
    When it processes first row, it checks for supervisor GE0064 which do not exist and so it errors out.
    Similarly for second row, it checks for supervisor EG0009 which again do not exist and so it errors out.
    So in order to prevent this, the cursor should process the rows as below
    Emp_Number     Supervisor_Number
    EG0001               TU0001
    EG0009               EG0001
    GE0064               EG0009
    GE0002               GE0064
    100009                EG0001
    By this way, Supervisor should be defined first as an employee and then it can be used as a supervisor for other employees
    is there a way that I can get the output as above(second set of data), when the table has records randomly as above(first set of data)
    Appreciate your help!
    Thanks,
    Srikanth

    Srikanth wrote:
    ... but the number of records returned by above query are lot more than number of records in the table.
    Why did the number go up?
    It's something only you can find out
    Maybe some Emp have several Supervisor(s) like
    with
    t as
    (select 'GE0002' Emp,'GE0064' Supervisor from dual union all
    select 'GE0064','EG0009' from dual union all
    select 'EG0009','EG0001' from dual union all
    select 'GE0064','100009' from dual union all
    select '100009','EG0001' from dual union all
    select 'EG0001','TU0001' from dual
    select Emp,Supervisor,lpad('_',3 * (level - 1),'_')||Emp indent
      from (select Emp,Supervisor
              from t
            union all
            select supervisor,null
              from t tt
             where not exists(select null
                                from t
                               where emp = tt.supervisor
    start with Supervisor is null
    connect by prior Emp = Supervisor
    EMP
    SUPERVISOR
    INDENT
    TU0001
    TU0001
    EG0001
    TU0001
    ___EG0001
    100009
    EG0001
    ______100009
    GE0064
    100009
    _________GE0064
    GE0002
    GE0064
    ____________GE0002
    EG0009
    EG0001
    ______EG0009
    GE0064
    EG0009
    _________GE0064
    GE0002
    GE0064
    ____________GE0002
    Regards
    Etbin

  • Need help in tunnig the query

    Experts,
    Plz help in tuning this query
    SELECT
    DECODE(WSH_DELIVERY_DETAILS.LOT_NUMBER,'5I27164/1U',1, TO_NUMBER(SUBSTR(WSH_DELIVERY_DETAILS.LOT_NUMBER, (LENGTH(WSH_DELIVERY_DETAILS.LOT_NUMBER) - INSTR(REVERSE(WSH_DELIVERY_DETAILS.LOT_NUMBER),'/') + 2), (INSTR(REVERSE(WSH_DELIVERY_DETAILS.LOT_NUMBER),'/')-1))) ) AS NO_OF_PLATES,
         P_FORM.DESCRIPTION FORMOFPRODUCT,
    HZ_PARTIES.PARTY_NAME CUSTOMER, HZ_CUST_ACCOUNTS.ACCOUNT_NUMBER ACCT_NUM,
         NVL(OE_ORDER_HEADERS_ALL.CUST_PO_NUMBER,'XXXX') CUST_PO,
         INITCAP(HZ_PARTIES.ADDRESS1) BILL_ADD1,
    INITCAP(HZ_PARTIES.ADDRESS2) BILL_ADD2,
    INITCAP(HZ_PARTIES.ADDRESS3) BILL_ADD3,
    INITCAP(HZ_PARTIES.ADDRESS4) BILL_ADD4,
         INITCAP(HZ_PARTIES.CITY) BILL_CITY,
    INITCAP(HZ_PARTIES.STATE) BILL_STATE,
    HZ_PARTIES.POSTAL_CODE BILL_PC,
         INITCAP(HZ_LOCATIONS.ADDRESS1) SHIP_ADD1,
    INITCAP(HZ_LOCATIONS.ADDRESS2) SHIP_ADD2,
    INITCAP(HZ_LOCATIONS.ADDRESS3) SHIP_ADD3,
    INITCAP(HZ_LOCATIONS.ADDRESS4) SHIP_ADD4,
         INITCAP(HZ_LOCATIONS.CITY) SHIP_CITY,
    INITCAP(HZ_LOCATIONS.STATE) SHIP_STATE,
    HZ_LOCATIONS.POSTAL_CODE SHIP_PC,
         OE_TRANSACTION_TYPES_TL.NAME CATEGORY ,
         OE_ORDER_HEADERS_ALL.ORDER_NUMBER,
    OE_ORDER_HEADERS_ALL.SOURCE_DOCUMENT_ID,
    OE_ORDER_HEADERS_ALL.HEADER_ID,
    OE_ORDER_HEADERS_ALL.FREIGHT_TERMS_CODE,
    /* to_char(oe_order_headers_all.ORDERED_DATE,'DD-MON-RR HH24:MI:SS') ORDER_DATE,*/
    to_char(sysdate,'DD/MM/RRRR HH24:MI:SS') ORDERED_DATE,
         ROWNUM,
    OE_ORDER_LINES_ALL.INVENTORY_ITEM_ID,
         OE_ORDER_LINES_ALL.ORDERED_ITEM,
         OE_ORDER_LINES_ALL.ORDERED_QUANTITY,
         WSH_DELIVERY_DETAILS.SHIPPED_QUANTITY+DECODE(WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID,129881,.22,0) AS SHIPPED_QUANTITY1, (WSH_DELIVERY_DETAILS.SHIPPED_QUANTITY+DECODE(WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID,129881,.22,0))*OE_ORDER_LINES_ALL.UNIT_SELLING_PRICE AS LINE_PRICE,
         OE_ORDER_LINES_ALL.UNIT_SELLING_PRICE,
         JA_IN_RG_I.FOR_HOME_USE_PAY_ED_VAL,
    ----      SUBSTR(JA_IN_RG_I.EXCISE_INVOICE_NUMBER,1,2)|| SUBSTR(JA_IN_RG_I.EXCISE_INVOICE_NUMBER,4,8) INVOICE_NO,
         JA_IN_RG_I.EXCISE_INVOICE_NUMBER INVOICE_NO,
    to_char(JA_IN_RG_I.CREATION_DATE,'DD/MM/RRRR') INVOICE_DATE1,
         to_char(JA_IN_RG_I.EXCISE_INVOICE_DATE,'DD-MON-RR HH24:MI:SS') INV_DATE,
         to_char(JA_IN_RG_I.CREATION_DATE,'DD/MM/RRRR HH24:MI:SS') INVOICE_DATE,
         JA_IN_RG_I.EXCISE_DUTY_RATE,
         JA_IN_RG_I.EXCISE_DUTY_AMOUNT,
         WSH_DELIVERY_DETAILS.LOT_NUMBER,
    WSH_TRIPS.CARRIER_ID CARRIER_ID,
    WSH_TRIPS.VEHICLE_NUM_PREFIX,
    WSH_TRIPS.SEAL_CODE,
    WSH_TRIPS.ROUTING_INSTRUCTIONS,
    WSH_TRIPS.OPERATOR, WSH_NEW_DELIVERIES. DELIVERY_ID,
    WSH_NEW_DELIVERIES. ADDITIONAL_SHIPMENT_INFO TRUCK_NO,
         WSH_TRIPS.MODE_OF_TRANSPORT VEHICLE_TYPE,
    WSH_TRIPS.ATTRIBUTE6||' '|| WSH_TRIPS.ATTRIBUTE7||' '|| WSH_TRIPS.ATTRIBUTE8 REMARKS,
         WSH_TRIPS.ATTRIBUTE1 LR_NO, WSH_TRIPS.ATTRIBUTE7,
         WSH_TRIPS.ATTRIBUTE2 LR_DATE,
         DECODE(WSH_TRIPS.ATTRIBUTE3, '', '', 'ARE NO '||WSH_TRIPS.ATTRIBUTE3) AS ARE_NO,
         DECODE(WSH_TRIPS.ATTRIBUTE6, '', '', WSH_TRIPS.ATTRIBUTE6) AS REMARK1,
         DECODE(WSH_TRIPS.ATTRIBUTE4, '', '', 'R.P. NO. ' ||WSH_TRIPS.ATTRIBUTE4) AS PERMIT,
         DECODE(WSH_TRIPS.ATTRIBUTE5, '', '', 'Export Under '||WSH_TRIPS.ATTRIBUTE5) AS EXPORT_UNDER,
         DECODE(WSH_NEW_DELIVERIES.PORT_OF_DISCHARGE,'','', 'Seal No : '||WSH_NEW_DELIVERIES.PORT_OF_DISCHARGE) AS SEAL_NO,
         DECODE(WSH_NEW_DELIVERIES.DESCRIPTION, '', '', 'Container No : ' ||WSH_NEW_DELIVERIES.DESCRIPTION) AS CONTAINER_NO,
         MTL_SYSTEM_ITEMS_B.ATTRIBUTE4 AS EXCISE_TARIFF_NO,
         --MTL_SYSTEM_ITEMS_B.DESCRIPTION,
         HZ_CUST_ACCOUNTS.ACCOUNT_NUMBER,
         JSW_LOT_PACKSLIP.PACKSLIP_NO PACKSLIP,
         PR_TYPE.DESCRIPTION ||' ,'||
         P_FORM.DESCRIPTION || ' ,'||
         PR_GRADE.DESCRIPTION ||' ,'||
         PR_QTY.DESCRIPTION || ' ,'||
         DECODE(SUBSTR(PR_STL.DESCRIPTION,1,3),'Not','', PR_STL.DESCRIPTION) DESCRIPTION ,
    HZ_CUST_ACCT_SITES_ALL.ATTRIBUTE7 S_CST_NO,
    HZ_CUST_ACCT_SITES_ALL.ATTRIBUTE6 S_LST_NO,
    HZ_CUST_ACCT_SITES_ALL.ATTRIBUTE5 S_ECC_NO,
    A.ATTRIBUTE7 B_CST_NO,
    A.ATTRIBUTE6 B_LST_NO,
    INTERFACECRM.JSW_MES_COMMON_TNGL_T.JSW_ADDMINUTES(WSH_TRIPS.VEHICLE_NUM_PREFIX) POSTFIX_NUM
    FROM -- jsw_vat_slno,
         MTL_PARAMETERS,
         HZ_PARTIES,
         HZ_CUST_ACCOUNTS,
         HZ_LOCATIONS,
         HZ_PARTY_SITES,
         HZ_CUST_ACCT_SITES_ALL,
         HZ_CUST_SITE_USES_ALL,
    HZ_CUST_ACCT_SITES_ALL A,
    HZ_CUST_SITE_USES_ALL B,
         OE_TRANSACTION_TYPES_TL,
         JA_IN_RG_I,
         WSH_DELIVERY_DETAILS,
         OE_ORDER_LINES_ALL,
         OE_ORDER_HEADERS_ALL,
         WSH_DELIVERY_ASSIGNMENTS,
         WSH_NEW_DELIVERIES,
         WSH_DELIVERY_LEGS,
         WSH_TRIP_STOPS,
         WSH_TRIPS,
         MTL_SYSTEM_ITEMS_B,
         JSW_LOT_PACKSLIP,
         IC_TRAN_PND,
                   JSW_ITM_SEARCH_PRD_TYP          PR_TYPE,
              JSW_ITM_SEARCH_PRD_FRM          P_FORM     ,
                   JSW_ITM_SEARCH_PRD_GRD          PR_GRADE,      
              JSW_ITM_SEARCH_QUALITY_LEVEL PR_QTY,      
                   JSW_ITEM_SEARCH_SLITTING      PR_STL
    WHERE /* jsw_vat_slno.excise_invoice_number=ja_in_rg_i.excise_invoice_number and jsw_vat_slno.organization_id = ja_in_rg_i.organization_id */
    HZ_PARTIES.PARTY_ID = HZ_CUST_ACCOUNTS.PARTY_ID
         AND HZ_CUST_ACCOUNTS.CUST_ACCOUNT_ID = OE_ORDER_HEADERS_ALL.SOLD_TO_ORG_ID
         AND OE_ORDER_HEADERS_ALL.SHIP_TO_ORG_ID = HZ_CUST_SITE_USES_ALL.SITE_USE_ID
         AND HZ_CUST_SITE_USES_ALL.CUST_ACCT_SITE_ID = HZ_CUST_ACCT_SITES_ALL.CUST_ACCT_SITE_ID
    AND OE_ORDER_HEADERS_ALL.INVOICE_TO_ORG_ID = B.SITE_USE_ID
         AND B.CUST_ACCT_SITE_ID                          = A.CUST_ACCT_SITE_ID
         AND HZ_CUST_ACCT_SITES_ALL.PARTY_SITE_ID      = HZ_PARTY_SITES.PARTY_SITE_ID
         AND HZ_PARTY_SITES.LOCATION_ID = HZ_LOCATIONS.LOCATION_ID
         AND OE_ORDER_LINES_ALL.SHIP_FROM_ORG_ID = MTL_PARAMETERS.ORGANIZATION_ID
         AND OE_ORDER_HEADERS_ALL.ORDER_TYPE_ID = OE_TRANSACTION_TYPES_TL.TRANSACTION_TYPE_ID
    and upper(oe_transaction_types_tl.description) not like '%SUP%'
         AND OE_ORDER_HEADERS_ALL.HEADER_ID = WSH_DELIVERY_DETAILS.SOURCE_HEADER_ID
         AND OE_ORDER_HEADERS_ALL.HEADER_ID = OE_ORDER_LINES_ALL.HEADER_ID
         AND OE_ORDER_LINES_ALL.LINE_ID = WSH_DELIVERY_DETAILS.SOURCE_LINE_ID
         AND TO_CHAR(WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID ) = JA_IN_RG_I.REF_DOC_ID
         AND WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID = WSH_DELIVERY_ASSIGNMENTS.DELIVERY_DETAIL_ID
         AND WSH_DELIVERY_ASSIGNMENTS.DELIVERY_ID = WSH_NEW_DELIVERIES.DELIVERY_ID
         AND WSH_NEW_DELIVERIES.DELIVERY_ID = WSH_DELIVERY_LEGS.DELIVERY_ID
         AND WSH_DELIVERY_LEGS.PICK_UP_STOP_ID = WSH_TRIP_STOPS.STOP_ID
         AND WSH_TRIP_STOPS.TRIP_ID                = WSH_TRIPS.TRIP_ID
    /* Input parameter can be either Invoice number or Delivery Id */
         AND (WSH_NEW_DELIVERIES.DELIVERY_ID = :DEL_ID OR JA_IN_RG_I.EXCISE_INVOICE_NUMBER = :INVOICE_NUMBER)
         AND NVL(WSH_DELIVERY_DETAILS.SHIPPED_QUANTITY,0) <>0
         AND     MTL_SYSTEM_ITEMS_B.ORGANIZATION_ID     = WSH_DELIVERY_DETAILS.ORGANIZATION_ID
         AND     MTL_SYSTEM_ITEMS_B.INVENTORY_ITEM_ID = WSH_DELIVERY_DETAILS.INVENTORY_ITEM_ID
         AND IC_TRAN_PND.LINE_DETAIL_ID               = WSH_DELIVERY_DETAILS.DELIVERY_DETAIL_ID
         AND     JSW_LOT_PACKSLIP.LOT_ID                    = IC_TRAN_PND.LOT_ID(+)
         AND     JSW_LOT_PACKSLIP.DELIVERY_ID          = WSH_NEW_DELIVERIES.DELIVERY_ID(+)
         AND      IC_TRAN_PND.LINE_ID                    = OE_ORDER_LINES_ALL.LINE_ID                                                  
         AND     IC_TRAN_PND.DELETE_MARK                = 0
         AND IC_TRAN_PND.COMPLETED_IND      = 1
         AND      IC_TRAN_PND.STAGED_IND                    =     1
         AND     P_FORM.CODE(+)                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,3,2)
         AND     PR_TYPE.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,1,2)
         AND     PR_TYPE.CODE                                   = P_FORM.PRD_TYPE_CODE
         AND     P_FORM.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,3,2)
    AND     P_FORM.CODE                                   = PR_GRADE.PRD_FRM_CODE
         AND     PR_GRADE.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,5,2)     
         AND     PR_GRADE.CODE                                   = PR_QTY.PRD_GRD_CODE
         AND     PR_QTY.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,7,2)
         AND     PR_STL.PROD_CODE                              = PR_TYPE.CODE
         AND     PR_STL.QUALITY_LEVEL_CODE                    = PR_QTY.CODE
         AND     PR_STL.CODE                                   = substr(OE_ORDER_LINES_ALL.ORDERED_ITEM,9,2)
         AND rownum=1
    thanks,
    baskar.l

    Here is the explain plan
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 1 | 920 | 12628 |
    | 1 | COUNT STOPKEY | | | | |
    | 2 | NESTED LOOPS | | 1 | 920 | 12628 |
    | 3 | NESTED LOOPS | | 1 | 728 | 12627 |
    | 4 | NESTED LOOPS | | 1 | 718 | 12626 |
    | 5 | NESTED LOOPS | | 1 | 684 | 12625 |
    | 6 | NESTED LOOPS | | 1 | 674 | 12624 |
    | 7 | NESTED LOOPS | | 1 | 665 | 12623 |
    | 8 | NESTED LOOPS | | 1 | 655 | 12622 |
    | 9 | NESTED LOOPS | | 1 | 532 | 12621 |
    | 10 | NESTED LOOPS | | 1 | 522 | 12620 |
    | 11 | FILTER | | | | |
    | 12 | NESTED LOOPS OUTER | | | | |
    | 13 | NESTED LOOPS | | 1 | 494 | 12617 |
    | 14 | NESTED LOOPS | | 1 | 477 | 12614 |
    | 15 | NESTED LOOPS | | 1 | 467 | 12611 |
    | 16 | NESTED LOOPS | | 1 | 382 | 12610 |
    | 17 | NESTED LOOPS | | 1 | 366 | 12609 |
    | 18 | NESTED LOOPS | | 1 | 321 | 12606 |
    | 19 | FILTER | | | | |
    | 20 | HASH JOIN OUTER | | | | |
    | 21 | TABLE ACCESS BY INDEX ROWID| IC_TRAN_PND | 1 | 22 | 3 |
    | 22 | NESTED LOOPS | | 1 | 292 | 12601 |
    | 23 | HASH JOIN | | 1 | 270 | 12598 |
    | 24 | NESTED LOOPS | | 4011 | 908K| 6272 |
    | 25 | HASH JOIN | | 4012 | 893K| 6272 |
    | 26 | TABLE ACCESS FULL | JSW_ITM_SEARCH_PRD_GRD | 33 | 759 | 2 |
    | 27 | HASH JOIN | | 20547 | 4113K| 6269 |
    | 28 | TABLE ACCESS FULL | JSW_ITM_SEARCH_QUALITY_LEVEL | 54 | 1296 | 2 |
    | 29 | HASH JOIN | | 24352 | 4304K| 6266 |
    | 30 | TABLE ACCESS FULL | JSW_ITM_SEARCH_PRD_TYP | 7 | 154 | 2 |
    | 31 | HASH JOIN | | 170K| 25M| 6260 |
    | 32 | TABLE ACCESS FULL | JSW_ITEM_SEARCH_SLITTING | 73 | 1971 | 2 |
    | 33 | HASH JOIN | | 44367 | 5719K| 6257 |
    | 34 | HASH JOIN | | 4469 | 410K| 367 |
    | 35 | TABLE ACCESS FULL| OE_TRANSACTION_TYPES_TL | 18 | 846 | 4 |
    | 36 | TABLE ACCESS FULL| OE_ORDER_HEADERS_ALL | 38240 | 1755K| 362 |
    | 37 | TABLE ACCESS FULL | OE_ORDER_LINES_ALL | 379K| 13M| 5761 |
    | 38 | INDEX UNIQUE SCAN | MTL_PARAMETERS_U1 | 1 | 4 | |
    | 39 | TABLE ACCESS FULL | WSH_DELIVERY_DETAILS | 579K| 21M| 5926 |
    | 40 | INDEX RANGE SCAN | IC_TRAN_PND_N1 | 2 | | 2 |
    | 41 | TABLE ACCESS FULL | JSW_ITM_SEARCH_PRD_FRM | 16 | 272 | 2 |
    | 42 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 1 | 12 | 2 |
    | 43 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | 1 |
    | 44 | TABLE ACCESS BY INDEX ROWID | JA_IN_RG_I | 1 | 45 | 3 |
    | 45 | INDEX RANGE SCAN | JA_IN_RG_I_N3 | 1 | | 2 |
    | 46 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 1 | 16 | 1 |
    | 47 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 1 | | |
    | 48 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 1 | 85 | 1 |
    | 49 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 1 | | |
    | 50 | TABLE ACCESS BY INDEX ROWID | WSH_DELIVERY_ASSIGNMENTS | 1 | 10 | 3 |
    | 51 | INDEX RANGE SCAN | WSH_DELIVERY_ASSIGNMENTS_N3 | 1 | | 2 |
    | 52 | TABLE ACCESS BY INDEX ROWID | JSW_LOT_PACKSLIP | 1 | 17 | 3 |
    | 53 | INDEX RANGE SCAN | JSW_LOT_PACKSLIP_N1 | 1 | | 2 |
    | 54 | TABLE ACCESS BY INDEX ROWID | WSH_NEW_DELIVERIES | 1 | 18 | 1 |
    | 55 | INDEX UNIQUE SCAN | WSH_NEW_DELIVERIES_U1 | 1 | | |
    | 56 | TABLE ACCESS BY INDEX ROWID | WSH_DELIVERY_LEGS | 1 | 10 | 2 |
    | 57 | INDEX RANGE SCAN | WSH_DELIVERY_LEGS_N1 | 1 | | 1 |
    | 58 | TABLE ACCESS BY INDEX ROWID | WSH_TRIP_STOPS | 1 | 10 | 1 |
    | 59 | INDEX UNIQUE SCAN | WSH_TRIP_STOPS_U1 | 1 | | |
    | 60 | TABLE ACCESS BY INDEX ROWID | WSH_TRIPS | 1 | 123 | 1 |
    | 61 | INDEX UNIQUE SCAN | WSH_TRIPS_U1 | 1 | | |
    | 62 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_SITE_USES_ALL | 1 | 10 | 1 |
    | 63 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 1 | | |
    | 64 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCT_SITES_ALL | 1 | 9 | 1 |
    | 65 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 1 | | |
    | 66 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_SITE_USES_ALL | 1 | 10 | 1 |
    | 67 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 1 | | |
    | 68 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCT_SITES_ALL | 1 | 34 | 1 |
    | 69 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 1 | | |
    | 70 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 1 | 10 | 1 |
    | 71 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 1 | | |
    | 72 | TABLE ACCESS BY INDEX ROWID | HZ_LOCATIONS | 1 | 192 | 1 |
    | 73 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 1 | | |
    we need to tune this query to reduce it time of execution as our users are very much affected in running requests.
    thanks,
    baskar.l

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

Maybe you are looking for

  • How to make an object disappear from screen?

    I am trying to make a simple pacman game in javafx. I've been stuck trying to get the pills to delete from screen once pacman "eats" them. I used a sequence to store the pills. I have collision detection working between the pills and pacman, i.e. the

  • Need advice about Oracle 10G ex

    Newbie question. I have set up Oracle db express on a Redhat Linux FC 8 box. It is in a workgroup with several MS computers. I have Samba runnning on the linux box and it shows up in XP network neighborhood. N\ow I need to access the ex Db instance r

  • Rss Feeds, Real Player Videos, and  flash player videos

    Hi all, Has anyone implemented Rss Feeds, Videos supported by real player, and flash videos on APEX application. Can anyone help me in this regard pls. With Regards, Sunil Bhatia

  • ABout SAP-ABAP Certification

    Dear Friends, I am planning to go for certification in ABAP. Will anyone help me to trace out the syllabus and books available for these. Thanking you, Aakash.

  • Need help to decipher "name" variations on Mac

    When I first set up my iMac recently, I used only Herschel Hochman to establish the account. By the time Mac was finished with it, I ended up with the following variations depending on what I was looking at: 1) Herschel Hochman 2) Herschel Hochman's