Query in jdeveloper using  distinct clause

hello
I am a user of oracle10G jdeveloper using jclient/swing
in my product.
I had written a query in my default view object as
Select distinct(Name) from emp then i test it.
Then message get displayed Query is valid.
But when i bind this view object with my form ie with combobox using model property and finally run the form then it throw an error message .
Please do help me to sort out this problem .
thanks

Please post the error message and the exception stack.
My guess is that the error is: your VO's SQL statement did not include the primary key attribute (say Empno).
Thanks.
Sung

Similar Messages

  • Problem with performance of a query having order by, distinct clause

    Hi,
    I have a problem with queries having order by, distinct clause.
    While its executing its taking lot of time. With DBMS_PROFILER identified the queries taking long time.
    The table is having approximately 70 million rows.
    Problem -1
    select * from table_name order by col1;
    select distinct col1,col2 from table_name;
    Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.
    Solution1:
    Max parallel servers is 8.
    select /* + parallel(table_name,8) */ * from table_name order by col1;
    select /* + parallel(table_name,8) */ distinct col1, col2 from table_name ;
    Solution-2:
    select /* + first_rows */ * from table_name order by col1;
    select /* + first_rows */ distinct col1, col2 from table_name ;
    Problem-2
    I am having a query with where condition on columns.
    Select * from table_name where col1='value1' and col2!='value2';
    Index created on col1 and col2.
    As we no that not equal won't use index as it is a composite index it should use the lead column. but its not using the index.
    Should i forcibly use index with hint or suggest me better solution.
    Any help really appreciated.
    Thanks in advance

    unique wrote:
    The table is having approximately 70 million rows.
    select * from table_name order by col1;Do you really want 70,000,000 rows from your table without any restrictions ? And furthermore ordered output ? I honestly understand the slowness of that query.
    Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.Who knows if you choosed the right solution. I would suggest to reconsider your query and the need of 70,000,000 returned rows.
    Problem-2
    I am having a query with where condition on columns.
    Select * from table_name where col1='value1' and col2!='value2';Please, provide the explain plan, eventually the tkprof output could also help. And tables descirption AND indexes description.
    And OS and Oracle version.
    Nicolas.

  • Execute a query in Jdeveloper using DB adpater

    Hi All ,
    In jdeveloper, using DB adapter i want to execute the following query ,
    select segment1,eng_item_flag from table_name where segment1 in ('itemnumber1',’itemnumber2’);
    In the query the operation IN got used so could you please help me to proceed further

    DB adpater wraps the parameter by ' (apostrophe), so using IN clause it becomes '1,2,3,4,5.........n' and the query returns nothing.
    You need to use below query in DB Adpater
    select attributes,attributes2 from table name where partnumber in (WITH VALUE_LIST AS
    (SELECT ? val FROM dual)
    SELECT SUBSTR(val, (decode(LEVEL, 1, 0, instr(val, ',', 1, LEVEL -1)) + 1), (decode(instr(val, ',', 1, LEVEL) -1, -1, LENGTH(val), instr(val, ',', 1, LEVEL) -1)) -(decode(LEVEL, 1, 0, instr(val, ',', 1, LEVEL -1)) + 1) + 1) a
    FROM VALUE_LIST CONNECT BY LEVEL <=
    (SELECT(LENGTH(val) -LENGTH(REPLACE(val, ',', NULL)))
    FROM VALUE_LIST) + 1)
    Value of <partnumber> tag can be mapped to DB Adapter Inputvariable.
    If you create a very big value list for IN query (greater than 4000 characters) you will get ORA-01704: string literal too long error. In that case you need to break value list and invoke this query multiple times.
    Thanks
    Ravdeep

  • Improving query which is using IN clause

    Hi,
    I am currently using a query which has IN (1.2.3....N) clause in where condition.
    The table has more than 100000 records in it. I have a set of 20 values which I pass inside this IN clause.
    The column which is used for IN clause is indexed.
    Can I use anything other than IN clause for this purpose?
    What is better way?
    Thanks,
    Plad

    > Can I use anything other than IN clause for this purpose? > What is better way?
    Sure you could use something else, but the IN clause would perfectly suit your needs. And the one who has to maintain the code after you are gone, will be glad you used IN, because it is as clear as you can get.
    If you are hinting at the fact that the query is too slow, then please read [url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]this thread and try to find out how many rows out of the 100K satisfy your IN predicate.
    Regards,
    Rob.

  • Need distinct rows with using distinct clause

    I have following requirement
    Empid startdate end organisation
    1 1-jan-2008 O1
    2 2-jan-2008 31-jul-08 O1
    3 2-jan-2008 31-jul-08 O1
    4 2-jan-2008 31-jul-08 O2
    5 2-jan-2008 31-jul-08 O2
    6 2-jan-2008 31-jul-08 O2
    7 2-jan-2008 31-jul-08 O3
    8 2-jan-2008 31-jul-08 O3
    My requirement is to get a sql query that report me something like this
    Empid startdate end organisation
    1 1-jan-2008 O1
    4 2-jan-2008 31-jul-08 O2
    7 2-jan-2008 31-jul-08 O3
    That is any empid, startdate, end for a given organization (ie organization should be distinct)
    regards
    vikas
    Edited by: user634784 on Jan 19, 2009 4:05 AM

    user634784 wrote:
    But is there any way to get the same outcome without using the subquery.In reality... No.
    You can hide the fact that you have to generate a row_number for the records by using a view... ;)
    SQL> ed
    Wrote file afiedt.buf
      1  create table t as select 1 as Empid, to_date('01-jan-2008','DD-MON-YYYY') as startdate, null as enddate, 'O1' as organisation from dual union all
      2                    select 2, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O1' from dual union all
      3                    select 3, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O1' from dual union all
      4                    select 4, to_date('5-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O2' from dual union all
      5                    select 5, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O2' from dual union all
      6                    select 6, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O2' from dual union all
      7                    select 7, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O3' from dual union all
      8*                   select 8, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O3' from dual
      9  /
    Table created.
    SQL> ed
    Wrote file afiedt.buf
      1  create view vw_x as
      2* select empid, startdate, enddate, organisation, row_number() over (partition by organisation order by empid) rn from t
    SQL> /
    View created.
    SQL> select * from vw_x where rn = 1;
         EMPID STARTDATE ENDDATE   OR         RN
             1 01-JAN-08           O1          1
             4 05-JAN-08 31-JUL-08 O2          1
             7 02-JAN-08 31-JUL-08 O3          1
    SQL>

  • Avoid distinct clause in the query

    hi i have a query from a single table using distinct clause and has columns (a,b,c,d,e,f,g,h,i)
    eg: select distinct a,b ,c,d from table
    where a<>0 and b<>0 and c<>0 and d<>0 and e=o and f=0 and g=0 and h=0 and i=0 ;
    when i see the execution plan with out distinct... it performs a bit faster.
    how do i remove distinct clause and make the query perform better
    this particular query is used as inline view in my vieiw . it is used in from clause .
    please suggest
    second question.... iam getting bitmap index to rowid conversion ...is this good? does it hamper performance . how to avoid this?
    regards
    raj
    Edited by: raj_fresher on Jul 17, 2009 7:48 AM

    Hi Raj
    what is e in the query ?It is the column name you provided yourself in your own unformatted example.
    After 400+ posts I thought you would understand that it's not that hard to put this exact tag => (yes, 6 characters, 4 letters between 2 curly brackets) before and after your code examples or sample data or explain plans.
    That way you maintain formatting and improve readability for us poor readers by magnitudes.
    But, I'm sure you'll succeed as well as all the others who can.
    I always look on the bright side.
    Example:
    Earlier this week another Raj also finally got enlightened about it, and his life has since then changed forever!
    +He drives a Bentley now, you know+ ;)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • SSRS reporting with sharepoint list using Distinct and Multivalue parameters

    i want create ssrs report with sharepoint list using ms-vs(2008). i want create Distinct multivalue parameters by using CAML query. There is any way we put CAML query where we use Distinct keyword and IN clause in CAML query... i hope all experts will
    understand my poor English... sorry for poor English.. plz help me

    Hi AsifMehmood,
    Per my understanding you have create an SSRS report with SharePoint list, now you don’t know to create the distinct parameters by using CAML query,  right?
    For the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results, but we can use the custom code to do this function. I have tested on my local environment and we can do that by create one hidden parameter(Param1)
    to get all the values from the fields which will  add the filter and then create another parameter(Param2) to get the distinct values based on the Param1, we use the custom code to do the deduplication.
    Step by Steps information in below thread for your reference to create the parameters and the custom code:
    "How to get distinct values of sharepoint column using SSRS"
    Other similar thread for your reference:
    https://audministrator.wordpress.com/2014/02/17/sharepoint-list-add-distinct-parameter-value/
    If your problem still exists, please feel free to ask and also try to provide us more details information.
    Regards
    Vicky Liu

  • I found out issue distinct clause in query ,refcursor not returning rows

    URGENT
    hi the following procedure returns records  but when i add  distinct clause to (open v_refcursor for select )
    i.e   open v_refcursor for select distinct column1,column2   .......... in the procedure the procedure is not returning records. please help what is the issue here?
    CREATE OR REPLACE procedure proc_shared_report3 (in_cust_id varchar2,in_user_array user_tab , in_acct_array acct_tab,in_report_pvlg_hier varchar2,in_fmt_pvlg_hier varchar2,v_refcursor OUT sys_refcursor)
    is
    BEGIN
    if  in_acct_array.count>0 and in_fmt_pvlg_hier is not null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null  then
    dbms_output.put_line('all are not null');
    *open v_refcursor for  select usr_id* from vw_get_user_profile where usr_id in (
            SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2  WHERE 
            up1.usr_id=up2.usr_id and
            up1.product_hierarchy=in_report_pvlg_hier  and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND up1.usr_id in (select usr_id from vw_get_user_for_customer where
            cust_id=in_cust_id)
            and up1.usr_id Member Of in_user_array) AND acct_nb Member of in_acct_array);
    /* if account list is null and rest all  not  null */
    elsif (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is not  null  and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null  then
    dbms_output.put_line('acc is null and rest are not null');
    *open v_refcursor for select usr_id,usr_type_cd* from vw_get_user_profile where usr_id in(SELECT  distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2  WHERE 
              up1.usr_id=up2.usr_id and
              up1.product_hierarchy=in_report_pvlg_hier and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND   up1.usr_id in (select usr_id from vw_get_user_for_customer where
              cust_id=in_cust_id)
              and up1.usr_id Member Of in_user_array);
    /* if account list is null and format pvlg hierarchy is null */
    elsif  (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null
    then
    dbms_output.put_line('acc is null and format is null null');
    *open v_refcursor for select usr_id,tmzon_cd* from vw_get_user_profile where usr_id in (
      (SELECT  distinct usr_id FROM vw_get_user_privileges  WHERE  product_hierarchy=in_report_pvlg_hier  AND   usr_id in (select usr_id from vw_get_user_for_customer where
       cust_id=in_cust_id)
       and usr_id Member Of in_user_array))  ;
    /* if account list is not null and format pvlg hierarchy is  null */
    else  -- If i get only one privilege and all other inputs then 
    dbms_output.put_line('acc list is not null and format pvlg is null');
    *open v_refcursor for select usr_id,prod_shrt_nm* from vw_get_user_profile where usr_id in (
         SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT  distinct usr_id FROM vw_get_user_privileges  WHERE 
         product_hierarchy=in_report_pvlg_hier  AND   usr_id in (select usr_id from vw_get_user_for_customer where
         cust_id=in_cust_id) and usr_id Member Of in_user_array ) AND acct_nb Member of in_acct_array);
    END IF;
    END proc_shared_report3;
    /Edited by: raj_fresher on Aug 12, 2009 8:50 AM
    Edited by: raj_fresher on Aug 12, 2009 1:40 PM

    its like this ...... ?
    You have to understand that without any testdata/ a reproducable testcase, all I can do is asking you to test some alternatives, I'm just guessing things from what I can make of your example, and hope you'll repost back any differences in a clear and concisive way.
    What I didn't understand is why you're not just joining your tables/views instead of using inner queries.
    Unfortunatly you're not providing any feedback on that, on the other hand you've narrowed down your problem to a specific part of your query? But you're not sharing why/what makes you decide to take that turn.
    But: you're still using inner queries in your reply.
    So, sorry, I cannot proceed/say anything useful unless you answer my previous post.
    Because, there are still many other questions/doubts: I don't understand why you're not aliasing your columns properly, for example.
    I don't know why you've suddenly switched to VW_GET_USER_cust_sa?
    I don't know if you've tried the straight join instead of nesting queries?
    And if you did, what's the problem?
    Please read and understand this, so you'll get your answers by the speed of light the next time you've got a question or problem:
    http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
    And don't refrain from using that tag ;)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Distinct clause and query performance

    Friends,
    I have a query which returns results in 40 seconds without distinct clause and when I add distinct clause it takes over 2 hours.
    I have verified following -
    1. indexes/table statistics are up to date.
    2. columns that are used in where clause but are not indexed have upto date column statistics
    Any idea what could be the reason, explain plan shows that distinct clause has a very expensive cost.
    Thanks
    Query and explain plan is below
    SELECT
    DISTINCT -- with distinct 2hrs + and without 40 seconds
    quote_by_dst.qte_hdr_stat_cd, quote_by_dst.qte_ln_cond_cd,
                    product.prod_nm, product.prod_id,
                    cs_ship_by_dst.bto_ds_cac_ownr_ud,
                    quote_by_dst.qte_csup_csup_am, cs_ship_by_dst.bto_ds_cac_nm,
                    product.spl_sht_nm,
                       product.prod_blg_un_fac_um
                    || ' '
                    || product.prod_blg_um
                    || ' '
                    || product.prod_stck_um,
                    product.prod_blg_um, quote_by_dst.qte_ln_brk_1_blg_uom_am,
                    quote_by_dst.qte_csup_avg_cst_am,
                    quote_by_dst.qte_csup_rev_gm_pct_am,
                    quote_by_dst.qte_csup_avg_cst_am, cs_ship_by_dst.bto_id,
                    cs_ship_by_dst.bto_ds_cac_cd,
                       cs_ship_by_dst.bto_ds_cac_cd
                    || product.prod_id
                    || cs_ship_by_dst.bto_id
               FROM infowhse.quote_by_dst4 quote_by_dst,
                    infowhse.product,
                    infowhse.cs_ship_by_dst4 cs_ship_by_dst,
                    infowhse.department
              WHERE (quote_by_dst.dpt_cd = department.dpt_cd)
                AND (quote_by_dst.cus_dpt_id = cs_ship_by_dst.cus_dpt_id)
                AND (product.prod_id = quote_by_dst.prod_id)
                AND (    (   quote_by_dst.qte_ln_cond_cd = 'E'
                          OR quote_by_dst.qte_ln_cond_cd = 'C'
                     AND quote_by_dst.qte_hdr_stat_cd = 'A'
                     AND ((cs_ship_by_dst.bto_cust_type_cd) = '01')
                     AND cs_ship_by_dst.bto_ds_cac_ownr_ud = 'EHOC'
                     AND department.dpt_cd > '0.00'
                    )Explain plan
    Plan
    SELECT STATEMENT  CHOOSECost: 911,832,256  Bytes: 433,941,639,459  Cardinality: 2,729,192,701                                               
         15 SORT UNIQUE  Cost: 911,832,256  Bytes: 433,941,639,459  Cardinality: 2,729,192,701                                          
              14 NESTED LOOPS  Cost: 68,705  Bytes: 433,941,639,459  Cardinality: 2,729,192,701                                     
                   12 HASH JOIN  Cost: 68,705  Bytes: 425,754,061,356  Cardinality: 2,729,192,701                                
                        1 INDEX FAST FULL SCAN NON-UNIQUE INFOWHSE.DST_SEC_DST_SEC_DST_CD_IX Cost: 25  Bytes: 922,700  Cardinality: 184,540                           
                        11 HASH JOIN  Cost: 16,179  Bytes: 1,199,209,082  Cardinality: 7,941,782                           
                             2 INDEX FAST FULL SCAN NON-UNIQUE INFOWHSE.DST_SEC_DST_SEC_DST_CD_IX Cost: 25  Bytes: 922,700  Cardinality: 184,540                      
                             10 HASH JOIN  Cost: 15,879  Bytes: 3,374,060  Cardinality: 23,110                      
                                  8 HASH JOIN  Cost: 15,200  Bytes: 2,981,190  Cardinality: 23,110                 
                                       6 HASH JOIN  Cost: 13,113  Bytes: 1,779,470  Cardinality: 23,110            
                                            3 TABLE ACCESS FULL INFOWHSE.CUSTOMER_SHIP Cost: 5,640  Bytes: 42,372  Cardinality: 1,177       
                                            5 PARTITION RANGE ALL  Partition #: 11  Partitions accessed #1 - #12     
                                                 4 TABLE ACCESS FULL INFOWHSE.QUOTE Cost: 7,328  Bytes: 38,826,590  Cardinality: 946,990  Partition #: 11  Partitions accessed #1 - #12
                                       7 TABLE ACCESS FULL INFOWHSE.PRODUCT Cost: 1,542  Bytes: 9,246,640  Cardinality: 177,820            
                                  9 INDEX FAST FULL SCAN NON-UNIQUE INFOWHSE.CUST_SHIP_SLSDST_DTP_SICALL_IX Cost: 185  Bytes: 9,878,411  Cardinality: 581,083                 
                   13 INDEX UNIQUE SCAN UNIQUE INFOWHSE.DEPARTMENT_PK Bytes: 3  Cardinality: 1                                

    This might be more useful.
    Query is still running.
    There is heavy wait time for scattered file read.
    Results from
    SELECT * FROM V$SESSION_WAIT WHERE SID = 48;
    SID   SEQ#  EVENT                           P1TEXT                          P1    P1RAW            P2TEXT                          P2    P2RAW            P3TEXT                          P3    P3RAW            WAIT_TIME                              SECONDS_IN_WAIT                        STATE              
    48    6865  db file scattered read          file#                           108   000000000000006C block#                          1593370000000000026E69 blocks                          32    0000000000000020 2                                      30                                      WAITED KNOWN TIME  
    SELECT * FROM V$SESSION_EVENT WHERE SID = 48;
    SID                                    EVENT                                                            TOTAL_WAITS                            TOTAL_TIMEOUTS                         TIME_WAITED                            AVERAGE_WAIT                           MAX_WAIT                               TIME_WAITED_MICRO                     
    48                                     log file sync                                                    1                                      0                                      0                                      0                                      0                                      563                                   
    48                                     db file sequential read                                          11                                     0                                      0                                      0                                      0                                      243                                   
    48                                     db file scattered read                                           6820                                   0                                      330                                    0                                      7                                      3296557                               
    48                                     SQL*Net message to client                                        19                                     0                                      0                                      0                                      0                                      23                                    
    48                                     SQL*Net message from client                                      18                                     0                                      128                                    7                                      127                                    1281912                                Sorry for long post.

  • Tunning the Query with Distinct Clause

    Hi All,
    I have the below query that returns 28113657 records
    select src_Wc_id, osp_id, src_osp_id
    from osp_complements o1
    where exists (select 1 from wc_crossref wc
                        where wc.src_wc_id = o1.SRC_WC_ID
                        and wc.state = 'CA')
    This query executes within a second...
    But when i include a DISTINCT clause in the select statement, it takes more time ... (more than 20 mins)
    I am trying to get it tunned. Please advice me with your knowledge to get it done
    Thanks for your time
    Kannan.

    Retrieving distinct rows requires a sort of all returned rows. 20 - 3 = ~17 mins for sorting 28 mln rows looks too much. You need to tune your instance in order to speed up sort operation. The amount of memory dedicated to sorts is controlled by PGA_AGGREGATE_TARGET parameter. If it's set to 0 (not recommended) then SORT_AREA_SIZE is used. The process of PGA tuning is quite complex and described in PGA Memory Management chapter of Performance Tuning Guide.
    There is a workaround which allows to bypass sort operation, but it requires proper index and proper access by that index. The idea is that rows rertrieved via index are automatically ordered by indexed columns. If that and only that columns (possibly - in the same order as in the index, I don't know) are selected using DISTINCT then sort is not actually performed. Rows are already sorted due to access via index.
    Hope this will help you.
    Regards,
    Dima

  • Query using where clause

    I am not able to run a SQL query using where clause.
    the query is as follows:
    I extract the text input by the user in a text field say 'a' and
    store it in string 'y'.
    String y= a.getText();
    //running the query
    Select A from B where B.x=y;
    how do we run a where clause when y is a string variable instead of value?

    Use the following :
    String y = a.getText();
    String query ="select A.CODE from Port A where A.NAME=" + "'" + y + "'" ;
    ResultSet rs= stmt.executeQuery(query);

  • Performance hit using "where" clause in the query

    Hi All,
    I am facing a huge performance hit in the java code when using "where" clause in queries. Following are the details:
    1. SELECT * FROM Employee
    2. SELECT * FROM Employee where employeeid in (26,200,330,571,618,945)
    There is no difference in Query Execution Time for both queries.
    Business Logic Time is huge in second case as compared to first one (ratio - 1:20).
    Rows returned are more in first case as compared to second case.(ratio - 1:4)
    Business Logic is same for both the cases where I iterate through the ResultSet, get the objects and set them in a data structure.
    Does anybody know the reason of unexpected time difference for the business logic in the second case?

    Since you're mentioning clustering your index, I'll assume you are using Oracle. Knowing what database you are using makes it a lot easier to suggest things.
    Since you are using Oracle, you can get the database to tell you what execution plan it is using for each of the 2 SQL statements, and figure out why they have similar times (if they do).
    First, you need to be able to run SQL*Plus; that comes as part of a standard database installation and as part of the Oracle client installation - getting it set up and running is outside the scope of this forum.
    Second, you may need your DBA to enable autotracing, if it's not already:
    http://asktom.oracle.com/~tkyte/article1/autotrace.html
    http://www.samoratech.com/tips/swenableautotrace.htm
    Once it's all set up, you can log in to your database using sql*plus, issue "SET AUTOTRACE ON", issue queries and get execution plan information back.
    For example:
    SQL> set autotrace on
    SQL> select count(*) from it.ticket where ticket_number between 10 and 20;
      COUNT(*)
            11
    Execution Plan
    Plan hash value: 2983758974
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            |     1 |     4 |     1   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |            |     1 |     4 |            |          |
    |*  2 |   INDEX RANGE SCAN| TICKET_N10 |    12 |    48 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TICKET_NUMBER">=10 AND "TICKET_NUMBER"<=20)
    Statistics
              0  recursive calls
              0  db block gets
              1  consistent gets
              0  physical reads
              0  redo size
            515  bytes sent via SQL*Net to client
            469  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> This tells me that this query used an INDEX RANGE SCAN on index TICKET_N1; the query can't do much better than that logically... In fact, the statistic "1 consistent gets" tells me that Oracle had to examine only one data block to get the answer, also can't do better than that. the statistic, "0 physical reads" tells me that the 1 data block used was already cached in Oracle's memory.
    the above is from Oracle 10g; autotrace is available back to at least 8i, but they've been adding information to the output with each release.
    If you have questions about sql_plus, check the forums at asktom.oracle.com or http://forums.oracle.com/forums/category.jspa?categoryID=18
    since sql*plus is not a JDBC thing...
    Oh, and sql*plus can also give you easier access to timing information, with "set timing on".

  • Possible to not use DISTINCT keyword in select query?

    I have a high repetition query that polls the database and only ever uses
    the first row returned from the query. Using the distinct keyword adds
    overhead and increases the use of tempdb in SQL Server in order to remove
    any duplicates. Is there a way to instruct kodo not to use distinct on an
    ad-hoc basis?
    We are using 3.2.3 on SQL Server 2000
    Regards
    Nathan

    Unfortunately, no.

  • Query to find no of peoples with the same age(using distinct)

    query to find no of peoples with the same age(using distinct)
    Edited by: swordfish3 on Mar 7, 2009 9:24 PM

    it would be helpful if you posted some proper sample data with proper expected results.
    The easier you make it for us to help you, the more likely you will get helped.

  • Suppress "Distinct" Clause from Answers Query

    Hello All:
    How can I suppress the "Distinct" clause that the BI Server issues to the Oracle Database?
    For Ex:
    I have a customer Table with FirstName and LastName as columns. If I Query FirstName and LastName in Answers, BI server sends a Query like this:
    select distinct T8944.fname as c1,
    T8944.lname as c2
    from
    CUSTOMER T8944
    order by c1, c2
    This will suppress customers having the same name even if their customer Id is different. I want their names included also.
    I would appreciate your help.
    Thanks
    rkingmdu

    AFAIK, there's no config setting or so to prevent this implicit grouping. What you can do though is to add the customer Id ot the report and make the column hidden (Column Format - Hide).
    Hth,
    Chris
    Edited by: Christian Berg on Sep 25, 2008 4:39 PM:
    Or what Matt said ;-) Should type faster...

Maybe you are looking for