Query rownum between help

I am running this query which doesnt work. no rows returned.
select rownum,doc_file_name,doc_id,doc_status,proj_title from(
select rownum,dm.doc_file_name,dm.doc_id,dm.doc_status,pm.proj_title from document_master dm,
(select proj_id,proj_title from project_master)pm
where dm.proj_id IN
(select proj_id
from project_master where upper(proj_title) LIKE '%SUPPLIER%')
and pm.proj_id=dm.proj_id
where rownum between 50000 and 100000
when i switch it to between 1-100000 works fine. I understand rownum has to increment from 1. But I am not sure how to get this to work. have about million rows have to export in chunks, like 50k - 100k, then 100k-150k, etc..
can someone help ?

ROWNUM is execution plan dependent (unless ORDER BY IS USED), so your query might return differnt set of rows next time you run it even if data did not change:
select  rn,
        doc_file_name,
        doc_id,
        doc_status,
        proj_title
  from  (
         select rownum rn,
                dm.doc_file_name,
                dm.doc_id,
                dm.doc_status,
                pm.proj_title
          from  document_master dm,
                 select proj_id,
                        proj_title
                  from  project_master
                ) pm
  where dm.proj_id IN (
                       select  proj_id
                         from  project_master
                         where upper(proj_title) LIKE '%SUPPLIER%'
    and pm.proj_id=dm.proj_id
  where rn between 50000 and 100000
/SY.

Similar Messages

  • Rownum Between Operator

    Hi,
    SELECT ROWNUM FROM DUAL WHERE ROWNUM BETWEEN 10 AND 20
    Returns 1;
    SELECT ROWNUM FROM DUAL WHERE ROWNUM BETWEEN 10 AND 20
    No Rows returned.
    Is that not possible to select rownum between two values.?

    Use subquery...
    Again dual is a one column one row table.You cant query like this even using a subquery..
    But you can use like this
    sql>
    select n+9 rn
    from(select rownum n
         from dual
        connect by level<= 11);
    RN 
    10 
    11 
    12 
    13 
    14 
    15 
    16 
    17 
    18 
    19 
    20 
    11 rows selected.
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Query about Search help exits

    Hi experts,
               I have one query regarding search help. I have created a elementary search help which is having two fields.Now my requirement is that in the selection screen when I will enter any value in one field and i will press F4 in other field the list should contain only the values corresponding to the first field.
    e.g.two fields comp code and name of company. When I will select the company code and press F4 in the second field the companies corresponding to the particular code should appear. Should I write a particular exit for that.
      Experts please help me.
      I will reward points accordingly.
      Thanks in advance,
        Abir.

    hi abir,
    no neeed for that.
    here i am fetching zones under a country.
    so first user enters a country.
    eg india.
    then on the zone field f4 help, only the zones of india shulod come.
    chk how i did it.
    *&      Form  F_GET_ZONE_DESC
          THIS SUB ROUTINE WILL FETCH THE ZONE DESCRIPTION
    -->  p1        F_GET_ZONE_DESC
    <--  p2        F_GET_ZONE_DESC
    FORM f_get_zone_desc .
      CLEAR int_ret.
      IF wf_country_code IS INITIAL.
    *--MESSAGE IS 'Country Not Selected'.
        MESSAGE s016(zm050).
      ELSE.
    *--THIS WILL FETCH THE ZONE CODES INTO THE INTERNAL TABLE'INT_ZONE_CODE'
    *--WITH RESPECT TO A COUNTRY CODE.
        SELECT zonecode zone_desc
          FROM zmpets_zone
            INTO TABLE int_zone_code
              WHERE land1 = wf_country_code
               AND loekz NE 'X'.
        IF sy-subrc NE 0.
    *MESSAGE IS 'No Zone Available In <COUNTRY_NAME>
          MESSAGE s019(zm050) WITH wf_country_desc.
        ELSE.
          CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
            EXPORTING
      DDIC_STRUCTURE         = ' '
              retfield               = 'WF_ZONE_CODE'
      PVALKEY                = ' '
      DYNPPROG               = ' '
      DYNPNR                 = ' '
      DYNPROFIELD            = ' '
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
             value_org              = 'S'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = ' '
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
      MARK_TAB               =
    IMPORTING
      USER_RESET             =
            TABLES
              value_tab              = int_zone_code
      FIELD_TAB              =
             return_tab             = int_ret
      DYNPFLD_MAPPING        =
           EXCEPTIONS
             parameter_error        = 1
             no_values_found        = 2
             OTHERS                 = 3
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
          READ TABLE int_ret INDEX 1." INTO INT_RET.
          wf_zone_code = int_ret-fieldval.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    " F_GET_ZONE_DESC
    rgds
    anver
    if helped mark points

  • Pass username and password ADFS without using query string, Please help.

    pass username and password ADFS without using query string, Please help.
    I used query string , but it is unsecured to pass credentials over url, with simple tool like httpwatch , anyone can easily get the password and decrypt it.

    Hi,
    According to your post, my understanding is that you had an issue about the ADFS.
    As this issue is related to ADFS, I recommend you post your issue to the forum for ADFS.
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=Geneva
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
    Thank you for your understanding and support.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Query regarding F4 Help

    Hi Experts,
    I need your help in solving a query about F4 help. I would like to know whether it is possible to return more than one column value from a F4 help. I am working on a scenario where, consider i have a table control with 3 columns. I have F4 helps for two columns. The third column which does not have the F4 help is the primary key and the two columns which have F4 help has repeated values. Consider the following values in the F4 help internal table.
    ColumnA  ColumnB  ColumnC
    1              01            10.09.2009
    2              01            10.09.2009
    3              01            10.09.2009
    Now consider the user selects first row '10.09.2009' in ColumnC and selects '01' from first row columnB from F4 help. I need to populate '1' in columnA of table control.  For this i am using read statement in PBO of my screen. But the read statement fails since ColumnB and ColumnC have repeated values. Kindly provide a solution to fix this problem. Is it possible to get the row id of the row selected by the user from F4 help? I am using the Fm F4IF_INT_TABLE_VALUE_REQUEST. This Fm returns a return_tab. The return_tab has a field record_pos which is 001 always. So it is of no use. Pls help me with a proper suggestion.
    Regards
    Rohan

    hi
    if u want an f4 help and get the other values in the row u need to write the code in process on values request.
    in PVR
    GET CURSOR LINE LINE.
      IF TC-TOP_LINE > 1.
        LINE = LINE + ( TC-TOP_LINE - 1 ).
      ENDIF.
    read table itab index line.
    in that itab u will get the values .

  • Use query string between two custom New Form

    Hi guys,
    i have a New Form . In this  form i have  a button that open(onClick) another list form (it is a  different list). I have to pass a field value from the first form to the other . How can i do this using query string?Help please!
    Thank you!

    To pass some value with query string, you just need to open the form url with the querystring parameters (jquery needed):
    var url = '<yourlist>/newform.aspx?parameter1=' + $('input[Title="Title"]').val()
    SP.UI.ModalDialog.ShowPopupDialog(url)
    on the second newform.aspx, you can grab the querystring parameters with the Sharepoint native function "_spGetQueryParam('<lower case query key>')"
    var x = _spGetQueryParam("parameter1")
    Note: make sure you use the key as lowercase, even you if pass it with chars in uppercase.

  • JHeadstart query operator between with date field

    Hallo,
    I am using JDeveloper 10.1.1.0.2 and JHeadstart 11 Technical Release 1.
    In my Application Definition Editor I use the Query Operator 'between' on a data-field. In my Application I can see a 'from' and 'to' date field.
    Testcase:
    In my table I have 3 dates: 1-1-2009, 17-1-2009 and 18-1-2009.
    If I use:
    Date from: 1-1-2009 and Date to: 18-1-2009 in my Application I expect to see only 2 rows (1-1-2009 and 17-1-2009). But I can see 3 rows.
    So my question is: what does 'to' mean in the JHeadstart generator? Does it include the date you fill in with the 'to' field?

    I can change the text in GeneratorText_nl.properties, but this does not completely solve my problem.
    I use a DateTimeField in my Application and if I use 'Date to' in my search criteria it seems that the Time of my Date-field is being ignored!
    Testcase:
    'Date to' in searchcriteria = 13-10-2009 *12:10:00* also gives results with the same date but time greater than 12:10:00, for example 13-10-2009 *16:10:00*.

  • Was doing the latest os update on my iphone 4 the update was interuptedby a bad internet connection and now the screen is stuck on an image of the itunes logo with a pic of the usb cord and an arrow in between HELP!!!n

    was doing the latest os update on my iphone 4 the update was interuptedby a bad internet connection and now the screen is stuck on an image of the itunes logo with a pic of the usb cord and an arrow in between HELP!!!n

    or you can try this
    http://www.iclarified.com/entry/index.php?enid=1034

  • Query Performance Please Help

    Hi can any body tell me how do I improve the performance of this query.This query takes forever to execute.
    PLEASE HELP
    select substr(d.name,1,14) "dist",
    sum(r.room_net_sq_foot) "nsf",
    sum(r.student_station_count) "sta",
    sum(distinct(r.cofte)) "fte"
    from b_fish_report r,
    g_efis_organization d
    where substr(r.organization_code,-2,2) = substr(d.code,-2,2) and
    d.organization_type = 'CNTY' and
    r.room_satisfactory_flag = 'Y' and
    substr(d.code,-2,2) between '01' and '72'
    -- rownum < 50
    group by d.name, r.organization_code
    order by d.name
    It has nonunique Indexes on Organization code
    Thanks
    Asma.

    Asma,
    I tried your SQL on my tables T1 and T2. Indexes are on C1,C2,C3 and N1,N2,N3. The data in T1 and T2 are shown below with the explain plan (also called EP) listed. You really need to do an explain plan (free TOAD is easiest to do this in) and respond showing your EP results.
    By simply changing the optimizer mode to RULE I was able to get it to use indexes on both T1 and T2.
    T1 data
    C1     C2     C3     N1     N2
    001     Y     AAA     1     11
    002     Y     BBB     2     22
    003     Y     CCC     3     33
    111     N     DDD     4     44
    222     N     EEE     5     55
    333     Y     FFF     6     66
    070     Y     GGG     7     77
    071     N     HHH     8     88
    072     Y     III     9     99
    TEST     TEST     TEST     10     100
    T2 data
    C1     C2     C3     N1     N2
    001     CNTY     AAA     1     11
    002     CNTY     BBB     2     22
    003     CNTY     CCC     3     33
    111     XXX     DDD     4     44
    222     XXX     EEE     5     55
    333     CNTY     FFF     6     66
    070     CNTY     GGG     7     77
    071     XXX     HHH     8     88
    072     CNTY     III     9     99
    TEST     TEST     TEST     10     100
    This is the results when I run the SQL based on this data ...
    dist     nsf     sta     fte
    AAA     1     11     10
    BBB     2     22     20
    CCC     3     33     30
    FFF     6     66     60
    GGG     7     77     70
    III     9     99     90
    --[SQL 1] : with CHOOSE as the optimizer mode, which is normally the DEFAULT if no hint is specified
    select /*+ CHOOSE */
    substr(d.c3,1,14) "dist",
    sum(r.n1) "nsf",
    sum(r.n2) "sta",
    sum(distinct(r.n3)) "fte"
    from t1 r, t2 d
    where substr(r.c1,-2,2) = substr(d.c1,-2,2) and
    d.c2 = 'CNTY' and
    r.c2 = 'Y' and
    substr(d.c1,-2,2) between '01' and '72'
    group by d.c3, r.c1
    order by d.c3
    This is what the EP shows for your SQL (which will probably be the same for you once you do an EP on your actuall sql) ...
    SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=1 Bytes=37)
    SORT (GROUP BY) (Cost=4 Card=1 Bytes=37)
    NESTED LOOPS (Cost=2 Card=1 Bytes=37)
    TABLE ACCESS (FULL) OF T1 (Cost=1 Card=1 Bytes=12)
    TABLE ACCESS (BY INDEX ROWID) OF T2 (Cost=1 Card=1 Bytes=25)
    INDEX (RANGE SCAN) OF I_NU_T2_C2 (NON-UNIQUE)
    Notice the FULL table scan of T1 which you don't want, and neither C1 index is getting used (I've explained why below).
    --[SQL 2] : only changed the hint to RULE ...
    select /*+ RULE */
    substr(d.c3,1,14) "dist",
    sum(r.n1) "nsf",
    sum(r.n2) "sta",
    sum(distinct(r.n3)) "fte"
    from t1 r, t2 d
    where substr(r.c1,-2,2) = substr(d.c1,-2,2) and
    d.c2 = 'CNTY' and
    r.c2 = 'Y' and
    substr(d.c1,-2,2) between '01' and '72'
    group by d.c3, r.c1
    order by d.c3
    SELECT STATEMENT Optimizer=HINT: RULE
    SORT (GROUP BY)
    NESTED LOOPS
    TABLE ACCESS (BY INDEX ROWID) OF T2
    INDEX (RANGE SCAN) OF I_NU_T2_C2 (NON-UNIQUE)
    TABLE ACCESS (BY INDEX ROWID) OF T1
    INDEX (RANGE SCAN) OF I_NU_T1_C2 (NON-UNIQUE)
    Though the C2 index is getting used (your r.c2 = 'Y' part in the where clause) the main problem your having here is the JOIN column (C1 in both tables) is not getting used. So the join you have ...
    where substr(r.c1,-2,2) = substr(d.c1,-2,2)
    isn't using an index and you want it too. There are 2 solutions to correct this..
    Solution #1
    The first is to make a function-based index for data. Since your doing SUBSTR on C1 that C1 index does not contain that partial information so it will not use it. Below is the syntax to make a function based index for this partial data ...
    CREATE INDEX I_NU_T1_C1_SUBSTR ON T1 (SUBSTR(C1,-2,2));
    CREATE INDEX I_NU_T2_C1_SUBSTR ON T2 (SUBSTR(C1,-2,2));
    or also this way if it's still not using the above indexes ...
    CREATE INDEX I_NU_T1_C1_SUBSTR ON T1 (SUBSTR(C1,-2,2),C1);
    CREATE INDEX I_NU_T2_C1_SUBSTR ON T2 (SUBSTR(C1,-2,2),C1);
    Solution #2
    The second solution is to make another column in both table and place this 2 digit information in it, and then index this new column. That way the join will look like ...
    where r.c_new_column = d.c_new_column
    and
    r.c_new_column between '01' and '72'
    also with this new column the BETWEEN clause at the end you will not need the substring as well. Also remember BETWEEN on character values is different than numbers.
    Final Notes
    I just tried creating the functional index and I can't get it to be used it for some reason (I might not have the right amount of data), but I really think that is your best option here. As long as it uses the functional index you won't have to change your code. You might want to try using INDEX() in the hint to get it to be used, but hopefully it will use it right away. Try all 4 types of optimizer modes (CHOOSE, RULE, ALL_ROWS, FIRST_ROWS) in your primary hints to see if it will use the new function-based index.
    You really do need to get explain plan going. Even if you make these functional indexes you won't know if its going to be using them until you look at the EP results. You can do EP manually (the SQL of how to produce the results is in OTN, though I find free TOAD is by far the easiest) and you will still need to have run the utlxplan.sql script. Oracle I do think has some GUI tools, maybe in OEM, that have explain plan built in as well.
    I hope this helps ya,
    Tyler D.

  • Query Performance Tuning - Help

    Hello Experts,
    Good Day to all...
    TEST@ora10g>select * from v$version;
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE     10.2.0.4.0     Production"
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
    NLSRTL Version 10.2.0.4.0 - Production
    SELECT fa.user_id,
              fa.notation_type,
                 MAX(fa.created_date) maxDate,
                                      COUNT(*) bk_count
    FROM  book_notations fa
    WHERE fa.user_id IN
        ( SELECT user_id
         FROM
           ( SELECT /*+ INDEX(f2,FBK_AN_ID_IDX) */ f2.user_id,
                                                      MAX(f2.notatn_id) f2_annotation_id
            FROM  book_notations f2,
                  title_relation tdpr
            WHERE f2.user_id IN ('100002616221644',
                                          '100002616221645',
                                          '100002616221646',
                                          '100002616221647',
                                          '100002616221648')
              AND f2.pack_id=tdpr.pack_id
              AND tdpr.title_id =93402
            GROUP BY f2.user_id
            ORDER BY 2 DESC)
         WHERE ROWNUM <= 10)
    GROUP BY fa.user_id,
             fa.notation_type
    ORDER BY 3 DESC;Cost of the Query is too much...
    Below is the explain plan of the query
    | Id  | Operation                                  | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                           |                                |    29 |  1305 |    52  (10)| 00:00:01 |
    |   1 |  SORT ORDER BY                             |                                |    29 |  1305 |    52  (10)| 00:00:01 |
    |   2 |   HASH GROUP BY                            |                                |    29 |  1305 |    52  (10)| 00:00:01 |
    |   3 |    TABLE ACCESS BY INDEX ROWID             | book_notations                 |    11 |   319 |     4   (0)| 00:00:01 |
    |   4 |     NESTED LOOPS                           |                                |    53 |  2385 |    50   (6)| 00:00:01 |
    |   5 |      VIEW                                  | VW_NSO_1                       |     5 |    80 |    29   (7)| 00:00:01 |
    |   6 |       HASH UNIQUE                          |                                |     5 |    80 |            |          |
    |*  7 |        COUNT STOPKEY                       |                                |       |       |            |          |
    |   8 |         VIEW                               |                                |     5 |    80 |    29   (7)| 00:00:01 |
    |*  9 |          SORT ORDER BY STOPKEY             |                                |     5 |   180 |    29   (7)| 00:00:01 |
    |  10 |           HASH GROUP BY                    |                                |     5 |   180 |    29   (7)| 00:00:01 |
    |  11 |            TABLE ACCESS BY INDEX ROWID     | book_notations                 |  5356 |   135K|    26   (0)| 00:00:01 |
    |  12 |             NESTED LOOPS                   |                                |  6917 |   243K|    27   (0)| 00:00:01 |
    |  13 |              MAT_VIEW ACCESS BY INDEX ROWID| title_relation                         |     1 |    10 |     1   (0)| 00:00:01 |
    |* 14 |               INDEX RANGE SCAN             | IDX_TITLE_ID                   |     1 |       |     1   (0)| 00:00:01 |
    |  15 |              INLIST ITERATOR               |                                |       |       |            |          |
    |* 16 |               INDEX RANGE SCAN             | FBK_AN_ID_IDX                  |  5356 |       |     4   (0)| 00:00:01 |
    |* 17 |      INDEX RANGE SCAN                      | FBK_AN_ID_IDX                  |   746 |       |     1   (0)| 00:00:01 |
    Table Details
    SELECT COUNT(*) FROM book_notations; --111367
    Columns
    user_id -- nullable field - VARCHAR2(50 BYTE)
    pack_id -- NOT NULL --NUMBER
    notation_type--     VARCHAR2(50 BYTE)     -- nullable field
    CREATED_DATE     - DATE     -- nullable field
    notatn_id     - VARCHAR2(50 BYTE)     -- nullable field      
    Index
    FBK_AN_ID_IDX - Non unique - Composite columns --> (user_id and pack_id)
    SELECT COUNT(*) FROM title_relation; --12678
    Columns
    pack_id - not null - number(38) - PK
    title_id - not null - number(38)
    Index
    IDX_TITLE_ID - Non Unique - TITLE_ID
    Please help...
    Thanks...

    Linus wrote:
    Thanks Bravid for your reply; highly appreciate that.
    So as you say; index creation on the NULL column doesnt have any impact. OK fine.
    What happens to the execution plan, performance and the stats when you remove the index hint?
    Find below the Execution Plan and Predicate information
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 126058086"
    "| Id  | Operation                                  | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |"
    "|   0 | SELECT STATEMENT                           |                                |    25 |  1125 |    55  (11)| 00:00:01 |"
    "|   1 |  SORT ORDER BY                             |                                |    25 |  1125 |    55  (11)| 00:00:01 |"
    "|   2 |   HASH GROUP BY                            |                                |    25 |  1125 |    55  (11)| 00:00:01 |"
    "|   3 |    TABLE ACCESS BY INDEX ROWID             | book_notations                 |    10 |   290 |     4   (0)| 00:00:01 |"
    "|   4 |     NESTED LOOPS                           |                                |    50 |  2250 |    53   (8)| 00:00:01 |"
    "|   5 |      VIEW                                  | VW_NSO_1                       |     5 |    80 |    32  (10)| 00:00:01 |"
    "|   6 |       HASH UNIQUE                          |                                |     5 |    80 |            |          |"
    "|*  7 |        COUNT STOPKEY                       |                                |       |       |            |          |"
    "|   8 |         VIEW                               |                                |     5 |    80 |    32  (10)| 00:00:01 |"
    "|*  9 |          SORT ORDER BY STOPKEY             |                                |     5 |   180 |    32  (10)| 00:00:01 |"
    "|  10 |           HASH GROUP BY                    |                                |     5 |   180 |    32  (10)| 00:00:01 |"
    "|  11 |            TABLE ACCESS BY INDEX ROWID     | book_notations                 |  5875 |   149K|    28   (0)| 00:00:01 |"
    "|  12 |             NESTED LOOPS                   |                                |  7587 |   266K|    29   (0)| 00:00:01 |"
    "|  13 |              MAT_VIEW ACCESS BY INDEX ROWID| title_relation                      |     1 |    10 |     1   (0)| 00:00:01 |"
    "|* 14 |               INDEX RANGE SCAN             | IDX_TITLE_ID                   |     1 |       |     1   (0)| 00:00:01 |"
    "|  15 |              INLIST ITERATOR               |                                |       |       |            |          |"
    "|* 16 |               INDEX RANGE SCAN             | FBK_AN_ID_IDX                  |  5875 |       |     4   (0)| 00:00:01 |"
    "|* 17 |      INDEX RANGE SCAN                      | FBK_AN_ID_IDX                  |   775 |       |     1   (0)| 00:00:01 |"
    "Predicate Information (identified by operation id):"
    "   7 - filter(ROWNUM<=10)"
    "   9 - filter(ROWNUM<=10)"
    "  14 - access(""TDPR"".""TITLE_ID""=93402)"
    "  16 - access((""F2"".""USER_ID""='100002616221644' OR ""F2"".""USER_ID""='100002616221645' OR "
    "              ""F2"".""USER_ID""='100002616221646' OR ""F2"".""USER_ID""='100002616221647' OR "
    "              ""F2"".""USER_ID""='100002616221648') AND ""F2"".""PACK_ID""=""TDPR"".""PACK_ID"")"
    "  17 - access(""FA"".""USER_ID""=""$nso_col_1"")"
    The cost is the same because the plan is the same. The optimiser chose to use that index anyway. The point is, now that you have removed it, the optimiser is free to choose other indexes or a full table scan if it wants to.
    >
    Statistics
    BEGIN
    DBMS_STATS.GATHER_TABLE_STATS ('TEST', 'BOOK_NOTATIONS');
    END;
    "COLUMN_NAME"     "NUM_DISTINCT"     "NUM_BUCKETS"     "HISTOGRAM"
    "NOTATION_ID"     110269     1     "NONE"
    "USER_ID"     213     212     "FREQUENCY"
    "PACK_ID"     20     20     "FREQUENCY"
    "NOTATION_TYPE"     8     8     "FREQUENCY"
    "CREATED_DATE"     87     87     "FREQUENCY"
    "CREATED_BY"     1     1     "NONE"
    "UPDATED_DATE"     2     1     "NONE"
    "UPDATED_BY"     2     1     "NONE"
    After removing the hint ; the query still shows the same "COST"
    Autotrace
    recursive calls     1
    db block gets     0
    consistent gets     34706
    physical reads     0
    redo size     0
    bytes sent via SQL*Net to client     964
    bytes received via SQL*Net from client     1638
    SQL*Net roundtrips to/from client     2
    sorts (memory)     3
    sorts (disk)     0
    Output of query
    "USER_ID"     "NOTATION_TYPE"     "MAXDATE"     "COUNT"
    "100002616221647"     "WTF"     08-SEP-11     20000
    "100002616221645"     "LOL"     08-SEP-11     20000
    "100002616221644"     "OMG"     08-SEP-11     20000
    "100002616221648"     "ABC"     08-SEP-11     20000
    "100002616221646"     "MEH"     08-SEP-11     20000Thanks...I still don't know what we're working towards at the moment. WHat is the current run time? What is the expected run time?
    I can't tell you if there's a better way to write this query or if indeed there is another way to write this query because I don't know what it is attempting to achieve.
    I can see that you're accessing 100k rows from a 110k row table and it's using an index to look those rows up. That seems like a job for a full table scan rather than index lookups.
    David

  • Query Output Formatting Help

    Hello All,
    I'm having problems trying to format the output of one of my queries. I'm new to SQL and I consider my writing the query a HUGE win.... but I can't seem to get the correct output format.
    Per the code below, it is outputting the Last Name (lname) of the employee, a count of what I want, and the overall rank.  I would like to concatenate the employee number (emp#) the first (fname) and last name (lname) together into the same column in the output.
    The concatenation code would be something like the below.
    Desired concatenation:
    emp# || ' - ' || lname || ', ' || fname AS EMPLOYEE
    I'm using Oracle 11g Express. Please let me know if you need any supporting information to assist you.
    I appreciate all your help!!! Thank you.
    Query
    SELECT EMPLOYEE, PREPARED,
    RANK() OVER (ORDER BY Prepared DESC) AS rank
    FROM (SELECT lname EMPLOYEE , COUNT(DISTINCT reportnum) PREPARED
          FROM employee
          LEFT OUTER JOIN faultreport USING (empno)
          GROUP BY lname
          ORDER BY Prepared DESC)
    WHERE rownum < 15;

    Hi,
    8bb7968b-e6ae-456c-8459-f418352e9e0a wrote:
    Hello All,
    I'm having problems trying to format the output of one of my queries. I'm new to SQL and I consider my writing the query a HUGE win.... but I can't seem to get the correct output format.
    Per the code below, it is outputting the Last Name (lname) of the employee, a count of what I want, and the overall rank.  I would like to concatenate the employee number (emp#) the first (fname) and last name (lname) together into the same column in the output.
    The concatenation code would be something like the below.
    Desired concatenation:
    emp# || ' - ' || lname || ', ' || fname AS EMPLOYEE
    I'm using Oracle 11g Express. Please let me know if you need any supporting information to assist you.
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    I appreciate all your help!!! Thank you.
    Query
    SELECT EMPLOYEE, PREPARED,
    RANK() OVER (ORDER BY Prepared DESC) AS rank
    FROM (SELECT lname EMPLOYEE , COUNT(DISTINCT reportnum) PREPARED
          FROM employee
          LEFT OUTER JOIN faultreport USING (empno)
          GROUP BY lname
          ORDER BY Prepared DESC)
    WHERE rownum < 15;
    It looks like you've found the right way to concatenate the columns.  How to use that in your query depends on your data, and what you want the query to do with that data.
    If you GROUP BY lname, what do you want the concatenated value to be when different rows having the same lname have different fnames and/or emp#s?
    Do you want to GROUP BY the new concatenated employee instead of lname?

  • SQL query performance between TOAD and APEX

    Hi Guys,
    I would like to know if there is any performance difference between a simple query run in TOAD and APEX(classic report).
    The reason being, I have a query based on a single table(conataining 15000 rows) which takes almost 30seconds in APEX whereas it takes just 2-3 seconds in TOAD.
    Thanks,
    Raj.

    Varad,
    Thanks for your suggestion.
    I tried changing the pagination but not much it helped.
    Basically I have 5 reports on the same page.
    When the user first navigates to this page then Report-1 is generated first with data as links to other reports.
    So I guess when I click on any of the column links on the Report-1 then the page is refreshed and this time its taking total time for Report-1 and Report-2.
    Is there a possibility that we can circumvent the execution of the first query or cache the results of report-1 so that when the page is refreshed it displays the data from the cache for Report-1 and executes the query for Report-2 ?
    -Raj

  • Perf tuning issue with a query involving between clause

    Hi all,
    I am getting issues with performance when I try to execute this query. Given below the query and it is going for a full table scan. I think the problem is with the between clause. But I dont know how to resolve this issue
    SELECT psm.member_id
    FROM pre_stg_member psm
    WHERE psm.map_tran_agn BETWEEN :start_transaction_agn and :end_transaction_agn
    and psm.partition_key = :p_partition_key;
    Having composite index on map_tran_agn and partition_key.
    Please help me in this regard.
    Thanks,
    Swami

    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Abap query, join between same tables

    Hi,
    I have an Abap Query (SQ01), I need to create a join between the same table (ESLL-ESLL) to obtain the services from a PO. The join is with the packno from ESLL to subpackno from ESLL (the same table). But I don't know how I can do that with Abap Query. Because the Infoset doesn't allow inserting the table two times.
    Somebody can help me.
    Thanks.
    Victoria

    Hi:
    I was able to create a query to retrieve the service lines entries using tables ESSR (Header) (service entry sheet number as input parameter), linked to package number to view ML_ESLL and then from the view the sup-package number linked to ESLL. That way I was able to retrieve all the service lines information from table ESLL only using SQ02 and SQ01, no ABAP.
    I Hope this help.
    Juan
    PS: I know the post is old but may be there are people out there with no ABAP access who needs to create reports for Service Entry Sheets lines. All the join conditions are.
    Table             Table
    ESSR            EKKO
    ESSR            ML_ESLL
    ML_ESLL      ESLL
    ESLL             ESLH
    Edited by: Juan Marino on Jan 23, 2012 10:53 PM

  • How to optimize this query? Please help

    i have one table(argus) having 80,000 rows and another table (p0f) having 30,000 rows and i have to join both table on the basis of time field. the query is as follows
    select distinct(start_time),res.port, res.dst_port from (select * from argus where argus.start_time between '2007-06-13 19:00:00' and '2007-06-22 20:00:00') res left outer join p0f on res.start_time=p0f.p0f_timestamp ;
    the query is taking very large time . i have created index on the start_time and p0f_timestamp ,it increased the performance but not so much. My date comparisons would vary every time i have to execute a new query.
    Plz tell me is there another way to execute such a query to output same results?
    plz help me as my records are increasing day by day
    Thanks
    Shaveta

    From my small testcase it seems that both queries are absolute identical and don't actually take too much time:
    SQL> create table argus as (select created start_time, object_id port, object_id dst_port from all_objects union all
      2                         select created start_time, object_id port, object_id dst_port from all_objects)
      3  /
    Table created.
    SQL> create table p0f as select created p0f_timestamp, object_id p0f_port, object_id p0f_dst_port from all_objects
      2  /
    Table created.
    SQL> create index argus_idx on argus (start_time)
      2  /
    Index created.
    SQL> create index p0f_idx on p0f (p0f_timestamp)
      2  /
    Index created.
    SQL>
    SQL> begin
      2   dbms_stats.gather_table_stats(user,'argus',cascade=>true);
      3   dbms_stats.gather_table_stats(user,'p0f',cascade=>true);
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select count(*) from argus
      2  /
      COUNT(*)
         94880
    SQL> select count(*) from p0f
      2  /
      COUNT(*)
         47441
    SQL>
    SQL> set timing on
    SQL> set autotrace traceonly explain statistics
    SQL>
    SQL> select distinct (start_time), res.port, res.dst_port
      2             from (select *
      3                     from argus
      4                    where argus.start_time between to_date('2007-06-13 19:00:00','RRRR-MM-DD HH24:MI:SS')
      5                                               and to_date('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS')) res
      6                  left outer join
      7                  p0f on res.start_time = p0f.p0f_timestamp
      8                  ;
    246 rows selected.
    Elapsed: 00:00:02.51
    Execution Plan
    Plan hash value: 1442901002
    | Id  | Operation               | Name    | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |         | 21313 |   520K|       |   250   (6)| 00:00:04 |
    |   1 |  HASH UNIQUE            |         | 21313 |   520K|  1352K|   250   (6)| 00:00:04 |
    |*  2 |   FILTER                |         |       |       |       |            |          |
    |*  3 |    HASH JOIN RIGHT OUTER|         | 21313 |   520K|       |    91  (11)| 00:00:02 |
    |*  4 |     INDEX RANGE SCAN    | P0F_IDX |  3661 | 29288 |       |    11   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL   | ARGUS   |  7325 |   121K|       |    79  (12)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS')<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS'))
       3 - access("ARGUS"."START_TIME"="P0F"."P0F_TIMESTAMP"(+))
       4 - access("P0F"."P0F_TIMESTAMP"(+)>=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "P0F"."P0F_TIMESTAMP"(+)<=TO_DATE('2007-06-22
                  20:00:00','RRRR-MM-DD HH24:MI:SS'))
       5 - filter("ARGUS"."START_TIME">=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "ARGUS"."START_TIME"<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
                  HH24:MI:SS'))
    Statistics
              1  recursive calls
              0  db block gets
            304  consistent gets
              0  physical reads
              0  redo size
           7354  bytes sent via SQL*Net to client
            557  bytes received via SQL*Net from client
             18  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            246  rows processed
    SQL>
    SQL> select distinct start_time, port, dst_port
      2             from argus left outer join p0f on start_time = p0f_timestamp
      3            where start_time between to_date ('2007-06-13 19:00:00','RRRR-MM-DD HH24:MI:SS')
      4                                       and to_date ('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS')
      5  /
    246 rows selected.
    Elapsed: 00:00:02.47
    Execution Plan
    Plan hash value: 1442901002
    | Id  | Operation               | Name    | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |         | 21313 |   520K|       |   250   (6)| 00:00:04 |
    |   1 |  HASH UNIQUE            |         | 21313 |   520K|  1352K|   250   (6)| 00:00:04 |
    |*  2 |   FILTER                |         |       |       |       |            |          |
    |*  3 |    HASH JOIN RIGHT OUTER|         | 21313 |   520K|       |    91  (11)| 00:00:02 |
    |*  4 |     INDEX RANGE SCAN    | P0F_IDX |  3661 | 29288 |       |    11   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL   | ARGUS   |  7325 |   121K|       |    79  (12)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS')<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS'))
       3 - access("START_TIME"="P0F_TIMESTAMP"(+))
       4 - access("P0F_TIMESTAMP"(+)>=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "P0F_TIMESTAMP"(+)<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
                  HH24:MI:SS'))
       5 - filter("ARGUS"."START_TIME">=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
                  HH24:MI:SS') AND "ARGUS"."START_TIME"<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
                  HH24:MI:SS'))
    Statistics
              1  recursive calls
              0  db block gets
            304  consistent gets
              0  physical reads
              0  redo size
           7354  bytes sent via SQL*Net to client
            557  bytes received via SQL*Net from client
             18  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            246  rows processedCan you show us a similar testcase with explain plan and statistics?

Maybe you are looking for

  • Software update hangs

    I have a 21.5 inch Intel iMac mid 2011 and all has been working perfectly since November 2011 when I bought it. The problem I am having is that when using the software update application found under the appleysumbol on the upper bar, the application

  • Can't import photos from camera

    I was downloading some photos from my Digital Rebel XSi with no problems. Then I switched cards and all of a sudden, it wouldn't load the photos. I could still view the photos on the camera, so they were definitely there. It was as if Aperture just d

  • BAPI_PO_CREATE1 use in a loop - net price issue

    Hi, I'm using BAPI_PO_CREATE1 within a loop to create a PO with multiple items - grouped by vendor, plant and delivery date. After each BAPI call I use BAPI_TRANSACTION_COMMIT with WAIT = 'X', further I track the results from BAPIRETURN into some kin

  • UTF8 characters not correctly displayed whilst having encoding set to UTF8

    Although the Encoding in Tools > Preferences > Environment is set to UTF8, SQL Developer is not able to display the UTF characters correctly. I know for sure that I have tested this before using an older version of SQL Developer and then then this wo

  • New MacMini and small touchscreen compatibility...

    Greetings, I'm trying to find either the correct (updated?) driver for a Lilliput 889GL-80NP/C/T touchscreen monitor (to be used with a new MacMini (2.0 GHz quad-core Intel Core i7 / 8 GB 1333 MHz DDR3 SDRAM running OS 10.7.3)... ...or a comparable s