Please help with a query

select * from testme;
NAME VAL
A 1
A 2
A 3
B 1
B 2
B 3
C 1
C 2
I want to get the maximum of name and the maximum of corresponding name's value.
ie., the answer should be
Name VAL
C     2
Please help me with the query.
Thnx

SQL> create table testme
  2  as
  3  select 'A' name, 1 val from dual union all
  4  select 'A', 2 from dual union all
  5  select 'A', 3 from dual union all
  6  select 'B', 1 from dual union all
  7  select 'B', 2 from dual union all
  8  select 'B', 3 from dual union all
  9  select 'C', 1 from dual union all
10  select 'C', 2 from dual
11  /
Tabel is aangemaakt.
SQL> select max(name) name
  2       , max(val) keep (dense_rank last order by name) val
  3    from testme
  4  /
NAME VAL
C      2Regards,
Rob.

Similar Messages

  • Please help with tricky query

    I need help with SQL query (if it can be accomplished with query at all).
    I'm going to create a table with structure similar to:
    Article_Name varchar2(30), Author_Name varchar2(30), Position varchar2(2). Position field is basicly position of an article author in the author list, e.g. if there is one author, his/her position is 0, if 2, then 1st author is 0, second is 1, etc.
    Article_Name Author_Name Position
    Outer Space Smith 0
    Outer Space Blake 1
    How can I automate creation of Position, based on number of authors on the fly? Let's say I have original table without Position, but I want to create a new table that will have this information.
    Regards

    If you have an existing table whose structure doesn't tell you what position the author is in, what's the algorithm you'd use to determine who was the first author, the second author, etc? If you issue a select query on a table without providing an "order by" clause, Oracle makes no guarantees about the order in which it retrieves rows.
    As an aside, why would you store position number in a varchar2 field? If it's a number, it ought to be stored as a number.
    Justin

  • Please help with some query

    hello all!
    please, help me again.
    we have a foreign key discrepancy and my task is to create a view which will show the 3 aspects.
    Let's we have 3 schemas: A - good (which means that i will compare WITH A, source)
    B and C are bad (which mean that I will checking this schemas).
    So, i need to obtain:
    1) FK that DO NOT exist in B&C and do exist in A
    2) FK that DO exist in bad schemas (B&C) but DO NOT exist in good schema (A)
    3) FK's that exist in both (A&B, A&C) schemas on the SAME TABLE, have THE SAME CONSTRAINT_NAME but are on the DIFFERENT columns.
    the first and second I seem to be done through the
    select CONSTRAINT_NAME, TABLE_NAME, STATUS from dba_constraints where owner='PRIV_MD' and CONSTRAINT_TYPE='R' and CONSTRAINT_NAME
    2 NOT IN (select CONSTRAINT_NAME from dba_constraints where owner ='MSA_MD'); (to get the second task we just reversing owners in query and subquery)
    query. but the third one is really pain in my back. i have a query:
    SELECT a.column_name, b.column_name FROM dba_cons_columns a, dba_cons_columns b, dba_constraints c, dba_constraints d
    WHERE c.CONSTRAINT_TYPE='R'
    AND a.CONSTRAINT_NAME = b.CONSTRAINT_NAME
    AND a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
    AND b.CONSTRAINT_NAME = d.CONSTRAINT_NAME
    AND a.owner = 'PRIV_MD' AND b.owner = 'MSA_MD';
    which runs hours and returns million of rows with the two columns with the same names... but if i'm adding
    AND a.column_name != a.column_name (i'm not sure it's a correct syntax)
    line it returns "no rows selected"
    please, help me obtain it, i'm fighting already the second day..
    (please, don't be angry, i'm just learning and this is my first task on my work...)

    This is basically just a UNION ALL (the constraint columns from both schemas)
    MINUS what exists in both (the INTERSECTion)
    I made it a little more complicated so you could see in which schema the column is used. You could use exactly the same approach for your questions 1 and 2 also.
    SELECT * FROM
    (SELECT a.column_name,c.constraint_name,'salive' schema_containing
    FROM dba_cons_columns a
    INNER JOIN dba_constraints c ON a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
    WHERE a.owner = 'SALIVE' and c.constraint_type = 'R'
    UNION ALL
    select b.column_name,d.constraint_name,'satest'
    FROM dba_cons_columns b
    INNER JOIN dba_constraints d ON b.CONSTRAINT_NAME = d.CONSTRAINT_NAME
    WHERE d.CONSTRAINT_TYPE='R' AND b.owner = 'SATEST') u
    WHERE NOT EXISTS
    (SELECT *
    FROM
    (SELECT a.column_name,c.constraint_name
    FROM dba_cons_columns a
    INNER JOIN dba_constraints c ON a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
    WHERE a.owner = 'SALIVE' and c.constraint_type = 'R'
    INTERSECT
    select b.column_name,d.constraint_name
    FROM dba_cons_columns b
    INNER JOIN dba_constraints d ON b.CONSTRAINT_NAME = d.CONSTRAINT_NAME
    WHERE d.CONSTRAINT_TYPE='R' AND b.owner = 'SATEST') i
    WHERE u.column_name = i.column_name and u.constraint_name = i.constraint_name)

  • Please help with the query (INSERT RETURNING BULK COLLECT INTO)

    I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
    Here is a full query that use in the C# code
    INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, BENEFICIARY_FIRST_NAME,
    BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE,
    LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL,
    ATTENDING_PROVIDER_NUMBER, BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI)
    VALUES
    (SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs,
    :REQUEST_METHOD_IDs, :SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs,
    :SERVICE_LOCATION_STATEs, :BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs,
    :HICNUMs, :CCNs, :CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs,
    :CONTRACTOR_IDs, :PRIORITY_IDs, :UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs,
    :ATTENDING_PROVIDER_NUMBERs, :BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs,
    :STUDY_IDs, :REFERRING_NPIs) RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs
    However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
    Please help me resolve this error or I would appreciate a different solution
    Thank you

    You cannot use (and do not want to in this case) the BULK COLLECT.
    create table for_testing
       the_id      number not null primary key,
       some_data   number
    declare
       l_return_value for_testing.the_id%type;
    begin
      4 
       insert into for_testing
          the_id,
          some_data
       values
          1,
          5
       returning the_id into l_return_value;
       dbms_output.put_line('the return values is ' || l_return_value);
    end;
    20  /
    the return values is 1
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.02
    TUBBY_TUBBZ?Is a simple example. In the future, please use the tags to preserve formatting on your code like i have so it remains readable .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Please help with RecordSet Query

    Hello all. I am trying to build a contact management system
    for different offices. Each person has a login they use to access
    their office's respective page. What I am wanting to do is pull up
    all the employees' information that work at the same location as
    the person who logged in. For example: Person A, B, and C work at
    Location 1 and Person X, Y, and Z work at location Z. If person A
    logs in, I want the to be able to see the dynamic table with the
    information for all of Location 1 (Person A, B, and C). I
    understand using the session variable MM_Username to filter the
    recordsets based off who logs in. Where I'm confused is in pulling
    up the records for everyone that shares the same location as the
    person who logs in. In other words, if I say filter Information
    based off Session Variable MM_Username it only returns the
    information for the person who logged in. I want it to say, in
    layman terms, Person A logged in, now look at their location, and
    return all Person's information who has a location equal to that of
    Person A. I hope I explained my dilemma clearly enough. If I need
    to elaborate or explain any more please let me know. Thanks in
    advance for any and all help.

    Thank you for your help. Sorry for my ignorance, but I'm
    still confused. I've made some changes to hopefully help. I have 1
    SQL table (called "Employees") with TableID, Username, Password,
    AccessLevel, and LocationID. I have another table (called
    "Names"-for testing purposes) with just TableID, Name, and
    LocationID. The query that I built, which doesn't work, is:
    SELECT `Names`.`Names`
    FROM Employees, `Names`
    WHERE Employees.Store_Number = `Names`.Store_Number
    I'm wanting it to simply display the names from the Names
    table that share the same LocationID as in the Employees Table. I
    realize that at this point it should just be a list of all the
    employee names from the Names table, but what it's doing is
    actually displaying 2 of every name. What do I need to do to set
    this up to where the MM_Username Session Variable generated at
    login grabs the LocationID from the Employee Table, then uses that
    LocationID and displays all the names from the Names Table with
    that same LocationID? I'm sorry for my lack of understanding, and I
    really appreciated the help.
    As a side note, why are there apostrophes around the Name
    Table but not the Employees Table in the query window? Thank you
    again.

  • Please help with a query were struggling with.

    Any help please, were struggling to get the result we require.
    We have Scheduled data returned from another program(job table). Shows our jobs 1 through 9 and the time that each job is loaded on a machine.
    i.e. if you look at the job table, job 1 is using machine 1 between 01-01-08 08:00 and 10-01-08 10:00.
    We then have a calendar table that shows our hours the machine is able to work.
    So machine 1 is available between 9-5.30 mon-fri but is not available on sat and Sunday.
    What we need to do is produce a graph that shows the time per day each machine is loaded.
    So if you see the result at the bottom, were hoping for something similar which shows for each machine, every day it is loaded and for how many hours.
    Thanks in advance
    Job TABLE with 4 columns
    JOB NUMBER
    MCR NUMBER
    START DATE
    FINISH DATE
    1,1,01-01-08 08:00, 10-01-08 10:00
    2,1,02-01-08 08:00, 03-01-08 10:00
    3,1,04-01-08 08:00, 04-01-08 10:00
    4,1,26-01-08 08:00, 26-01-08 10:00
    5,1,19-01-08 08:00, 26-01-08 10:00
    6,1,20-01-08 08:00, 21-01-08 10:00
    7,2,01-01-08 08:00, 10-01-08 10:00
    8,2,02-01-08 08:00, 03-01-08 10:00
    9,2,05-01-08 08:00, 06-01-08 10:00
    Calender TABLE WITH 3 COLUMNS
    MCR     NUMBER
    START     DATE
    END     DATE
    1,MON 09-30, MON 17-30
    1,TUE 09-30, MON 17-30
    1,WED 09-30, MON 17-30
    1,THU 09-30, MON 17-30
    1,FRI 09-30, MON 17-30
    1,SAT 00-00, MON 00-00
    1,SUN 00-00, MON 00-00
    RESULT
    MCR
    DATE IN USE
    HOURS IN USE
    1,01-01-08,8
    1,02-01-08,16
    1,03-01-08,16
    1,04-01-08,10
    1,05-01-08,0
    1,06-01-08,0
    etc
    Obviously these are not real figures but hopefully you get the idea!

    Thanks Keith.
    SQL> create table job_table
      2  as
      3  (
      4  select 1 machine_id,to_date('01-01-08 08:00','dd-mm-yy hh24:mi') started, to_date('10-01-08 10:00','dd-mm-yy hh24:mi') finished fr
    om dual union all
      5  select 1,to_date('02-01-08 08:00','dd-mm-yy hh24:mi'), to_date('03-01-08 10:00','dd-mm-yy hh24:mi') from dual union all
      6  select 1,to_date('04-01-08 08:00','dd-mm-yy hh24:mi'), to_date('04-01-08 10:00','dd-mm-yy hh24:mi') from dual union all
      7  select 1,to_date('26-01-08 08:00','dd-mm-yy hh24:mi'), to_date('26-01-08 10:00','dd-mm-yy hh24:mi') from dual union all
      8  select 1,to_date('19-01-08 08:00','dd-mm-yy hh24:mi'), to_date('26-01-08 10:00','dd-mm-yy hh24:mi') from dual union all
      9  select 1,to_date('20-01-08 08:00','dd-mm-yy hh24:mi'), to_date('21-01-08 10:00','dd-mm-yy hh24:mi') from dual union all
    10  select 2,to_date('01-01-08 08:00','dd-mm-yy hh24:mi'), to_date('10-01-08 10:00','dd-mm-yy hh24:mi') from dual union all
    11  select 2,to_date('02-01-08 08:00','dd-mm-yy hh24:mi'), to_date('03-01-08 10:00','dd-mm-yy hh24:mi') from dual union all
    12  select 2,to_date('05-01-08 08:00','dd-mm-yy hh24:mi'), to_date('06-01-08 10:00','dd-mm-yy hh24:mi') from dual
    13  );
    Table created.
    SQL> create table calendar_table as
      2  (
      3  select 1 machine_id,'MON 09-30' startdate , 'MON 17-30' enddate from dual union all
      4  select 1,'TUE 09-30', 'TUE 17-30' from dual union all
      5  select 1,'WED 09-30', 'WED 17-30' from dual union all
      6  select 1,'THU 09-30','THU 17-30' from dual union all
      7  select 1,'FRI 09-30','FRI 17-30' from dual union all
      8  select 1,'SAT 00-00','SAT 00-00' from dual union all
      9  select 1,'SUN 00-00','SUN 00-00' from dual
    10  );
    Table created.
    SQL> select j.machine_id
      2       , trunc(j.startdate) day_in_use
      3       , sum
      4         (  least(j.enddate,trunc(j.startdate) + (c.enddate-trunc(c.enddate)))
      5          - greatest(j.startdate,trunc(j.startdate) + (c.startdate-trunc(c.startdate)))
      6         ) * 24 hours_in_use
      7    from ( select j.machine_id
      8                , greatest(j.started,trunc(j.started) - 1 + row_number() over (partition by j.rowid order by null)) startdate
      9                , least(j.finished,trunc(j.started) + row_number() over (partition by j.rowid order by null)) enddate
    10             from job_table j
    11                , table
    12                  ( cast
    13                    ( multiset(select null from dual connect by level <= trunc(j.finished) - trunc(j.started) + 1)
    14                      as sys.dbms_debug_vc2coll
    15                    )
    16                  ) t
    17         ) j
    18       , ( select machine_id
    19                , substr(enddate,1,3) dayofweek
    20                , to_date(substr(startdate,5),'hh24-mi') startdate
    21                , to_date(substr(enddate,5),'hh24-mi') enddate
    22             from calendar_table
    23            where enddate not like '___ 00-00'
    24         ) c
    25   where c.machine_id = j.machine_id
    26     and c.dayofweek = to_char(j.startdate,'DY','nls_date_language=american')
    27   group by j.machine_id
    28       , trunc(j.startdate)
    29   order by j.machine_id
    30       , trunc(j.startdate)
    31  /
                                MACHINE_ID DAY_IN_USE                                    HOURS_IN_USE
                                         1 01-01-2008 00:00:00                                      8
                                         1 02-01-2008 00:00:00                                     16
                                         1 03-01-2008 00:00:00                                    8.5
                                         1 04-01-2008 00:00:00                                    8.5
                                         1 07-01-2008 00:00:00                                      8
                                         1 08-01-2008 00:00:00                                      8
                                         1 09-01-2008 00:00:00                                      8
                                         1 10-01-2008 00:00:00                                     .5
                                         1 21-01-2008 00:00:00                                    8.5
                                         1 22-01-2008 00:00:00                                      8
                                         1 23-01-2008 00:00:00                                      8
                                         1 24-01-2008 00:00:00                                      8
                                         1 25-01-2008 00:00:00                                      8
    13 rows selected.Regards,
    Rob.

  • Please help with chart query

    Hello, i am trying to display a line chart, for some sales data.
    I want a line (series) for each product, X axis should be the years in the data
    (2007, 2008, 2009 there is no more data than these years)
    The plan is to eventually use a "Function Returning SQL Query" to get dynamic series.
    But i tried to hardcode 2 lines for 2 products first to try it out.
    I used this query in SQL Workshop > SQL Commands
    to view the data i want and it works correctly
    Query1:
    SELECT product.major_brand, timeperiod.year, SUM(sales_fact.euro_sales) AS sales
    FROM sales_fact
    INNER JOIN product ON sales_fact.product_id = product.product_id
    INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
    GROUP BY product.major_brand, timeperiod.year
    ORDER BY product.major_brand, timeperiod.year ASCI have tried the following query for the chart but it will show 2 flat lines
    with the value 0 for each year.
    Query2:
    SELECT NULL
          ,timeperiod.year
          ,SUM(decode(product.major_brand, 'BELCINO', sales_fact.euro_sales, 0)) "BELCINO"
          ,SUM(decode(product.major_brand, 'BIORGANIC', sales_fact.euro_sales, 0)) "BIORGANIC"
    FROM sales_fact
    INNER JOIN product ON sales_fact.product_id = product.product_id
    INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
    GROUP BY product.major_brand, timeperiod.yearThanks for reading,
    Any help is appreciated!
    Edited by: 908157 on 15-jan-2012 5:22
    Edited by: 908157 on 15-jan-2012 5:22

    Thanks Jeff for the quick response,
    I have looked at the examples, tried some things
    and found out that my GROUP BY was the problem.
    Apperantly i only have to GROUP BY on year and not also on product.
    I dont fully understand why yet,
    i guess the query gets parsed and translated to 2 queries, one for each line, that makes sense
    This is the query that worked for me:
    SELECT NULL
          ,t.year
          ,SUM(decode(p.major_brand, 'BELCINO', s.euro_sales, 0)) "BELCINO"
          ,SUM(decode(p.major_brand, 'BIORGANIC', s.euro_sales, 0)) "BIORGANIC"
    FROM sales_fact s, product p, timeperiod t
    WHERE s.product_id = p.product_id
    AND s.timeperiod_id = t.timeperiod_id
    GROUP BY t.year
    ORDER BY t.yearThanks again!

  • Please help with the query creating Materialized View

    Hi,
    We are using the below query to create a Materialized View but it has been running since 3 hours. It is an Oracle 9i database running in HP-UX.The quey is as follows,
    (SELECT
    /*+ use_nl(A) parallel (A,4)*/
    A.ICD_CODE AS ICD_CODE,
    A.ICD_DESC AS ICD_DESC,
    A.PROC_GROUP as PROC_GROUP,
    B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
    B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
    C.PROC_TYPE AS PROC_TYPE ,
    C.I_O_IND AS I_O_IND,
    C.DISC_MON AS QUARTER ,
    B.PAT_KEY AS PAT_KEY ,
    D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
    C.PROV_ID AS PROV_ID ,
    A.SPECIALTY AS SPECIALTY
    FROM
    EES_ICD_9_CODE A ,
    EES_CLINICAL_COMPL_DATA B,
    EES_CLINICAL_DATA C,
    EES_CLINCL_COMPL_ICD D                                                                            
    WHERE A.ICD_CODE= B.ICD_CODE
                    AND B.ICD_CODE= C.ICD_CODE
                    AND B.COMPL_ICD_CODE=D.ICD_9_CD
                    AND B.PAT_KEY=C.PAT_KEY
                    AND B.COMPL_ICD_CODEB.ICD_CODE
                    AND C.PROC_TYPE  'L'
                    AND B.COMPL_GRP_TXT'Reoperations'
                    AND D.COMPL_TYPE_TXT'Intra-operative Misadventure'
                    AND C.DISC_MON>='2003101'
                    AND A.SPECIALTY='Colo-Rectal')
    union
    (SELECT
    /*+ use_nl(A) parallel (A,4)*/
    A.ICD_CODE AS ICD_CODE,
    A.ICD_DESC AS ICD_DESC,
    A.PROC_GROUP as PROC_GROUP,
    B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
    B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
    C.PROC_TYPE AS PROC_TYPE ,
    C.I_O_IND AS I_O_IND,
    C.DISC_MON AS QUARTER ,
    B.PAT_KEY AS PAT_KEY ,
    D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
    C.PROV_ID AS PROV_ID ,
    A.SPECIALTY AS SPECIALTY
    FROM
    EES_ICD_9_CODE A ,
    EES_CLINICAL_COMPL_DATA B,
    EES_CLINICAL_DATA C,
    EES_CLINCL_COMPL_ICD D                                                                            
    WHERE A.ICD_CODE= B.ICD_CODE
                    AND B.ICD_CODE= C.ICD_CODE
                    AND B.COMPL_ICD_CODE=D.ICD_9_CD
                   AND B.PAT_KEY=C.PAT_KEY
                    AND B.COMPL_ICD_CODEB.ICD_CODE
                    AND C.PROC_TYPE  'L'
                    --AND B.COMPL_GRP_TXT'Reoperations'
                    AND D.COMPL_TYPE_TXT='Intra-operative Misadventure'
                    AND B.PROC_DAY=C.PROC_DAY
                    AND C.DISC_MON>='2003101'
                    AND A.SPECIALTY='Colo-Rectal')
    union
    (SELECT
    /*+ use_nl(A) parallel (A,4)*/
    A.ICD_CODE AS ICD_CODE,
    A.ICD_DESC AS ICD_DESC,
    A.PROC_GROUP as PROC_GROUP,
    B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
    B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
    C.PROC_TYPE AS PROC_TYPE ,
    C.I_O_IND AS I_O_IND,
    C.DISC_MON AS QUARTER ,
    B.PAT_KEY AS PAT_KEY ,
    D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
    C.PROV_ID AS PROV_ID ,
    A.SPECIALTY AS SPECIALTY
    FROM
    EES_ICD_9_CODE A ,
    EES_CLINICAL_COMPL_DATA B,
    EES_CLINICAL_DATA C,
    EES_CLINCL_COMPL_ICD D                                                                            
    WHERE A.ICD_CODE= B.ICD_CODE
                    AND B.ICD_CODE= C.ICD_CODE
                    AND B.COMPL_ICD_CODE=D.ICD_9_CD
                    AND B.PAT_KEY=C.PAT_KEY
                    AND B.COMPL_ICD_CODEB.ICD_CODE
                    AND C.PROC_TYPE  'L'
                    AND B.COMPL_GRP_TXT='Reoperations'
                    --AND D.COMPL_TYPE_TXT='Intra-operative Misadventure'
                    AND B.PROC_DAY>C.PROC_DAY
                    AND C.DISC_MON>='2003101'
                    AND A.SPECIALTY='Colo-Rectal')
    The explain plan is as follows,
    PLAN_TABLE_OUTPUT
    | Id  | Operation                          |  Name                    | Rows  | Bytes |TempSpc| Cost  |  TQ    |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT                   |                          | 46935 |  6716K|       | 10648 |        |      |            |
    |   1 |  SORT UNIQUE                       |                          | 46935 |  6716K|    14M| 10648 | 45,14  | P->S | QC (RAND)  |
    |   2 |   UNION-ALL                        |                          |       |       |       |       | 45,13  | P->P | HASH       |
    |*  3 |    HASH JOIN                       |                          | 42801 |  6102K|       |  4640 | 45,13  | PCWP |            |
    |*  4 |     TABLE ACCESS FULL              | EES_CLINCL_COMPL_ICD     |   875 | 18375 |       |     2 | 45,02
    |*  5 |     HASH JOIN                      |                          | 41552 |  5072K|    14M|  4638 | 45,13  | PCWP |            |
    |*  6 |      TABLE ACCESS FULL             | EES_CLINICAL_DATA        |  1430K|    40M|       |  2855 | 45,03
    |*  7 |      HASH JOIN                     |                          |   628K|    56M|       |   494 | 45,10  | P->P | HASH       |
    |*  8 |       TABLE ACCESS FULL            | EES_ICD_9_CODE           |    37 |  2183 |       |     1 | 45,08 
    |*  9 |       TABLE ACCESS BY INDEX ROWID  | EES_CLINICAL_COMPL_DATA  |  2090K|    71M|       |   49
    |  10 |        BITMAP CONVERSION TO ROWIDS |                          |       |       |       |       |        |    
    |* 11 |         BITMAP INDEX FULL SCAN     | INX_COMPL_GRP            |       |       |       |       |        |
    |* 12 |    TABLE ACCESS BY INDEX ROWID     | EES_CLINICAL_DATA        |     1 |    33 |       |     1
    |  13 |     NESTED LOOPS                   |                          |  1327 |   196K|       |   947 | 45,13  | PCWP |            |
    |* 14 |      HASH JOIN                     |                          | 60205 |  6996K|       |   495 | 45,13  | PCWP |            |
    |  15 |       TABLE ACCESS BY INDEX ROWID  | EES_CLINCL_COMPL_ICD     |    36 |   756 |       |    
    |* 16 |        INDEX RANGE SCAN            | COMPL_TYPE_TXT_3         |     1 |       |       |     1 |     
    |* 17 |       HASH JOIN                    |                          |  1420K|   132M|       |   494 | 45,13  | PCWP |            |
    |* 18 |        TABLE ACCESS FULL           | EES_ICD_9_CODE           |    37 |  2183 |       |     1 | 45,11 
    |* 19 |        TABLE ACCESS BY INDEX ROWID | EES_CLINICAL_COMPL_DATA  |  4722K|   175M|       |   49
    |  20 |         BITMAP CONVERSION TO ROWIDS|                          |       |       |       |       |        |      |           
    |  21 |          BITMAP INDEX FULL SCAN    | INX_COMPL_GRP            |       |       |       |       |        |
    |* 22 |      INDEX RANGE SCAN              | EES_CLINICAL_DATA_IND1   |     1 |       |       |     2 | 45,13
    |* 23 |    HASH JOIN                       |                          |  2807 |   416K|       |  4695 | 45,13  | PCWP |            |
    |  24 |     TABLE ACCESS FULL              | EES_CLINCL_COMPL_ICD     |   911 | 19131 |       |     2 | 45,06
    |* 25 |     HASH JOIN                      |                          |  2617 |   334K|    15M|  4693 | 45,13  | PCWP |            |
    |* 26 |      TABLE ACCESS FULL             | EES_CLINICAL_DATA        |  1430K|    45M|       |  2855 | 45,07
    |* 27 |      HASH JOIN                     |                          |   791K|    74M|       |   305 | 45,12  | P->P | HASH       |
    |* 28 |       TABLE ACCESS FULL            | EES_ICD_9_CODE           |    37 |  2183 |       |     1 | 45,09 
    |* 29 |       TABLE ACCESS BY INDEX ROWID  | EES_CLINICAL_COMPL_DATA  |  2632K|    97M|       |   30
    |  30 |        BITMAP CONVERSION TO ROWIDS |                          |       |       |       |       |        |    
    |* 31 |         BITMAP INDEX SINGLE VALUE  | INX_COMPL_GRP            |       |       |       |       |        |
    Predicate Information (identified by operation id):
       3 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
       4 - filter("D"."COMPL_TYPE_TXT"'Intra-operative Misadventure')
       5 - access("B"."ICD_CODE"="C"."ICD_CODE" AND "B"."PAT_KEY"="C"."PAT_KEY")
       6 - filter("C"."PROC_TYPE"'L' AND "C"."DISC_MON">=2003101)
       7 - access("A"."ICD_CODE"="B"."ICD_CODE")
       8 - filter("A"."SPECIALTY"='Colo-Rectal')
       9 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
      11 - filter("B"."COMPL_GRP_TXT"'Reoperations')
      12 - filter("B"."ICD_CODE"="C"."ICD_CODE" AND "C"."PROC_TYPE"'L' AND "B"."PROC_DAY"="C"."PROC_DA
      14 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
      16 - access("D"."COMPL_TYPE_TXT"='Intra-operative Misadventure')
      17 - access("A"."ICD_CODE"="B"."ICD_CODE")
      18 - filter("A"."SPECIALTY"='Colo-Rectal')
      19 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
      22 - access("B"."PAT_KEY"="C"."PAT_KEY")
      23 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
      25 - access("B"."ICD_CODE"="C"."ICD_CODE" AND "B"."PAT_KEY"="C"."PAT_KEY")
           filter("B"."PROC_DAY">"C"."PROC_DAY")
      26 - filter("C"."PROC_TYPE"'L' AND "C"."DISC_MON">=2003101)
      27 - access("A"."ICD_CODE"="B"."ICD_CODE")
      28 - filter("A"."SPECIALTY"='Colo-Rectal')
      29 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
      31 - access("B"."COMPL_GRP_TXT"='Reoperations')
    Note: cpu costing is offPlease help.

    Try removing the hints.
    Is 47,000 a reasonable estimate of how many rows you expect in the results?
    See these posts for other information that you should supply.
    HOW TO: Post a SQL statement tuning request
    HOW TO: Post a SQL statement tuning request - template posting
    When your query takes too long
    When your query takes too long ...

  • Please help with this query!

    Hi All,
    I have this this table:
    Term Grade
    term_A A
    term_A A
    term_A B
    term_A B
    term_B D
    term_B F
    term_B F
    term_C C
    How do I display so that it appears this way?
    term_A A 2
    term_A B 2
    term_B D 1
    term_B F 2
    term_C C 1
    Thank you. Appreciate all the help!

    Please read about [url http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#sthref962]aggregate functions in the manual.
    Regards,
    Rob.

  • Can ANYONE please help with coding query?

    Hi
    Im currently setting a website up in Adobe Muse/BC - Im not a developer at all!..but a designer and really like this software. However ive come across whats probably quite a simple problem - i just need to put some the module output from my web app over an image on template page but i dont know how to do it.
    The page is here:
    latest
    The text and image im moving (this is web app outputt) is inserted into the page coding as:
    {tag_pagecontent}
    This is a module that Adobe BC is placing on the page from my web app.
    Ive done images to explain this far more clearly:
    http://www.paulsuttontestsite.co.uk/test.SHOT1.png
    http://www.paulsuttontestsite.co.uk/test.SHOT2.png
    Many thanks in advance to anyone who is kind enough to offer their time in helping me.
    Paul

    Have a look at this and check your version number see if its listed
    http://forum.xda-developers.com/showthread.php?t=1186045
    As for generic roms you have probable read about custom roms
    See this thread it is a stock SE rom not a custom rom and will give you just that a stock SE rom if you want
    http://talk.sonyericsson.com/thread/19762

  • Please, need help with a query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Take a look on the syntax :
    max(...) keep (dense_rank last order by ...)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#i1000901
    Nicolas.

  • Please need help with this query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Perhaps something like this...
    select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
    from (
          select distinct a.id,
                          create_date,
                          a.loanid,
                          a.rate,
                          a.pays,
                          a.gracetime,
                          a.emailtosend,
                          d.first_name,
                          d.last_name,
                          a.user_id,
                          max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
          from CLAL_LOANCALC_DET a,
               loan_Calculator b,
               bv_user_profile c,
               bv_mr_user_profile d
          where b.loanid = a.loanid
          and   c.NET_USER_NO = a.resp_id
          and   d.user_id = c.user_id
          and   a.is_partner is null
          and   a.create_date between
                TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
                TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    where create_date = max_create_date
    order by create_date

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • HT5824 I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. Please help with turning my iMessage completely off..

    I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. I have no problem sending the text messages but I'm not receivng any from iPhones at all. It has been about a week now that I'm having this problem. I've already tried fixing it myself and I also went into the sprint store, they tried everything as well. My last option was to contact Apple directly. Please help with turning my iMessage completely off so that I can receive my texts.

    If you registered your iPhone with Apple using a support profile, try going to https://supportprofile.apple.com/MySupportProfile.do and unregistering it.  Also, try changing the password associated with the Apple ID that you were using for iMessage.

  • How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore. Please help with proper steps, if any.

    How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore.
    On the new computer, I am getting a message that my all purchases would be deleted if I sync it with new iTunes library.
    Please help with proper steps, if any.

    Also see... these 2 Links...
    Recovering your iTunes library from your iPod or iOS device
    https://discussions.apple.com/docs/DOC-3991
    Syncing to a New Computer...
    https://discussions.apple.com/docs/DOC-3141

Maybe you are looking for

  • Employee Contract Letters need to be Generated

    Hi All, I need to generate Employee Contract Letters for this should I use WebADI or XML Publisher or any other solution , kindly suggest me. Regards,

  • How to read table of accounts to read in step 2 the single accounts

    Hi, I want to write a litle MIS-Report with diverse FI-management-ratios. At the first screen (selection-screen) the user has to specify the table of accounts. So I have to know, how I can read an "table of accounts" in ABAP. That means the hierachy

  • Any Quality loss in FCE using H.264

    I have shot video using the new Canon SX30is with 720p. The files are H.264 (1280x720). I have put them directly into FCE and then rendered them. This took some time, but worked fine. My question is did I loose any quality be doing this? I saved it a

  • AIX 6.2 how to config Scheduler obiee 10.1.3.4

    Hi AIX Experts I have Install AIX 6.2 server OBIEE 10.1.3.4. how to config Schedulaer in Aix server I am getting this error when I am trying to save an Ibot. Oracle BI Scheduler Error: [nQSError: 12008] Unable to connect to port 9705 on machine sbigs

  • EMAIL FOR MOBILE PRINTING AND REGISTERING WITH HP

    Just bought a Deskjet 2540 printer, have managed set up but have two questions Where do I get the required email for printing from a smartphone (tried my register email but that doesn't work) Trying to register my printer with HP by clicking on produ