TIPS(64) : ORDERING 된 상위 "N" ROWS 만 RETRIEVE 하는 SQL문

제품 : SQL*PLUS
작성날짜 : 2002-12-20
ORDERING 된 상위 "N" ROWS 만 RETRIEVE 하는 SQL문
===============================================
PURPOSE
다음은 특정 Column 으로 Ordering 된 상위 "n" rows 만 Return 하기 위한
간단한 SQL 문을 소개한다.
Explanation
Example
SELECT *
FROM table A
WHERE n >= (SELECT COUNT(*)
FROM table B
WHERE B.column >= A.column)
ORDER BY column DESC;
예) Emp Table 에서 Salary 가 많은 상위 5명만 구하는 SQL 문
SQL> select empno,ename,sal
2 from emp A
3 where 5 >= (select count(*)
4 from emp B
5 where B.sal >= A.sal)
6 order by sal desc
7 /
EMPNO ENAME SAL
7839 KING 5000
7788 SCOTT 3000
7902 FORD 3000
7566 JONES 2975
7698 BLAKE 2850
5 rows selected.
->Oracle 8i 이상인 경우
다음과 같이 간단히 query 할수 있다.
1 select empno,ename,sal
2 from (select * from emp order by sal desc)
3* where rownum <= 5;
위의 예는 상위 "n" Rows 만 정확히 Return 한다. 그러나 중복된
Column Value 를 가진다면 다음의 예를 고려해 보아야 할 것이다.
SELECT *
FROM table A
WHERE n >= (SELECT COUNT(DISTINCT column)
FROM column B
WHERE B.column >= A.column)
ORDER BY column DESC;
예)
SQL> select empno,ename,sal
2 from emp A
3 where 5 >= (select count(distinct sal)
4 from emp B
5 where B.sal >= A.sal)
6 order by sal desc
7 /
EMPNO ENAME SAL
7839 KING 5000
7788 SCOTT 3000
7902 FORD 3000
7566 JONES 2975
7698 BLAKE 2850
7782 CLARK 2450
6 rows selected.
Reference Documents
none

Similar Messages

  • Order of rows retrieved from collection

    hi -- If I do not specify an ORDER BY clause when selecting rows from a collection, is
    there any pre-defined order in which they'll be returned? (Eg perhaps in the order each
    row is added to the collection...)
    I ask because I've been using a particular collection for ages, but forgot to specify
    an order when querying from it. Just today it returned the rows in a different order
    than it has in the past -- only once -- and then they were returned as before.
    The order I want -- and have been getting -- is the order in which they're added to the collection.
    Will the 'no query transformation' hint accomplish this, or do I need a member that specifies the order?
    Thanks,
    C

    Never mind... got it.

  • How to execute procedure returning data rows from sql plus

    Hi,
    I want to execute a stored procedure that returns data rows from sql plus. please let me know the syntax for the same.
    Thanks,
    YG

    user13065317 wrote:
    Even if i get the result set into the cursor, do i have to do normal fetch into all the coumn variables within a loop
    But suppose no of columns in my result set varies depending on a parameter to the stored procedure.
    Is there any straightforward way to retrieve all the data irrespective of no of columns in the result set.There is no such thing as a "+result set+". Oracle does not create a temporary data set in memory that contains the results of your query. What would happen if this result set is a million rows and is too large to fit into memory? Or there are a 100 clients each with a 100,000 row result set?
    This is not scalable. You will be severely limited in the number and sizes of these "+result sets+" that can be created in server memory.
    A cursor is in fact a "program" that is created by compiling the SQL source code that you provide. This source code is parsed and compiled into what Oracle calls an execution plan. This is nothing but a series of instructions that the cursor will execute in order to return the rows required.
    Thus the result set is actually the output from a cursor (a program). Likewise, bind variables are the input parameters to this program.
    All SQLs are parsed and compiled as cursors and stored in the SQL Shared Pool. Oracle gives you handle in return to use to address this cursor - bind values to it, execute it, describe the output structure returned by the cursor, and fetch the output from the cursor.
    On the client side, this handle is used in different ways. In PL/SQL alone, this cursor handle can be used as an implicit cursor (you do not even see or use the cursor handle in your PL/SQL code). Or you can use a PL/SQL cursor variable. Or a DBMS_SQL cursor variable. Or a reference cursor variable.
    Why so many different client structures for the very same SQL cursor handle returned by Oracle? Because to allow you, the programmer, all kinds of different features and flexibility.
    The ref cursor feature is the ability to pass this cursor handle around, not only between PL/SQL code, but also from PL/SQL to the actual client process (Java. VB, SQL*Plus, TOAD, etc).
    The primary thing to remember - irrespective of what the client calls this (e.g. ref cursor, SQL statement handle, etc), this all refers to the same SQL cursor in the Shared Pool. And that this SQL cursor is a program that outputs data, and not a result set in itself.

  • How to preset the order of rows in the outer query of a correlated query ?

    Good morning,
    I have the following simple query:
    select empno,
           ename,
           sal,
           sum(case
                 when rn = 1 then sal
                 else -sal
               end) over (order by sal, empno) as running_diff
       from (
             select empno,
                    ename,
                    sal,
                    row_number() over (order by sal, empno) as rn
               from emp
              where deptno = 10
             );That calculates a running difference and uses "row_number() over (...)" which is an Oracle specific feature to do so. It yields the following result (which we will consider correct):
         EMPNO ENAME             SAL RUNNING_DIFF
          7934 MILLER           1300         1300
          7782 CLARK            2450        -1150
          7839 KING             5000        -6150I wanted to come up with a solution that was not Oracle specific different solution. I tried the following code:
    (EDIT: after additional thought, that code is totally different in meaning and will never come close, to the above result. Consider it wrong and ignore this attempt altogether.)
    select a.empno,
           a.ename,
           a.sal,
           (select case
                     when a.empno = min(b.empno) then sum(b.sal)
                     else sum(-b.sal)
                   end
              from emp b
             where b.empno <= a.empno
               and b.deptno = a.deptno) as running_diff
      from emp a
    where a.deptno = 10;but the result is
         EMPNO ENAME             SAL RUNNING_DIFF
          7782 CLARK            2450         2450
          7839 KING             5000        -7450
          7934 MILLER           1300        -8750which is a long way from the original result. I've tried everything I could think of to order the rows before the running difference is calculated but, have been unsuccessful.
    Is there a way to change this second query --(without using Oracle specific features)-- without using windowing features that would yield the same result as the first query ?
    Rephrase of the above question:
    Is there a way, using plain vanilla SQL (that is aggregate functions and set operations such as joins and unions) to create a query that yields the same result as the first one ?
    Also, this is not for production code. This is simply an exercise in set manipulation that I'd like to see a solution for.
    Thank you for your help,
    John.
    Edited by: 440bx - 11gR2 on Jul 18, 2010 12:50 AM - correct "ho w" to "How"
    Edited by: 440bx - 11gR2 on Jul 18, 2010 1:42 AM - struck out all references to row_number and windowing features being Oracle specific features.
    Edited by: 440bx - 11gR2 on Jul 18, 2010 3:51 AM - Noted that my try is woefully wrong and restated the objective to make it clearer.

    Hi, John,
    One way to get a running total (which is basically what you want) is to do a self-join. Join each row (let's call it the current row, or c) to itself and everything that came before it (let's call this the previous row, or p), and do a regular aggregate SUM, like this:
    WITH     got_base_sal     AS
         SELECT       deptno
         ,       2 * MIN (sal)     AS base_sal
         FROM       scott.emp
         GROUP BY  deptno
    SELECT       c.deptno
    ,       c.empno
    ,       c.ename
    ,       c.sal
    ,       b.base_sal - SUM (p.sal)     AS running_diff
    FROM       scott.emp     c
    JOIN       scott.emp     p     ON     c.deptno     = p.deptno
                        AND     (     c.sal     > p.sal
                             OR     (     c.sal     =  p.sal
                                  AND     c.empno     >= p.empno
    JOIN       got_base_sal     b     ON     c.deptno     = b.deptno
    WHERE       c.deptno     IN (10)
    GROUP BY  c.deptno
    ,       c.empno
    ,       c.ename
    ,       c.sal
    ,       b.base_sal
    ORDER BY  c.deptno
    ,       running_diff     DESC
    ;Output:
        DEPTNO      EMPNO ENAME             SAL RUNNING_DIFF
            10       7934 MILLER           1300         1300
            10       7782 CLARK            2450        -1150
            10       7839 KING             5000        -6150I said you basically want a runninng total. There are two differences between a running total and your requirements
    (1) You want to have a total of the negative of what's in the table. That's trivial: use a minus sign.
    (2) You want the first item to count as positive instead of negative. That's not so trivial. The query above counts all sals as negative, but adds an offset so that it appears as if the first item had been counted as positive, not negative.
    You didn't say what you want to do in case of a tie (two or more rows having the same sal). The query above uses empno as a tie-breaker, so that all sals are calculated as if they were distinct. This is similar to what analytic functions do when the windowing is based on rows. If you want something similar to windowing by range, that might actually be simpler.
    The query above calculates a separate running_diff for each deptno, similar to "PARTITION BY deptno" in analytic functions. You happen to be interested in only one deptno right now, but you can change the main query's WHERE clause, or omit it, and the query will still work. If you don't want this feature (analagoud to not having any PARTITION BY), it's easy to modify the query.
    You could also get these results using a recursive WITH clause. That meets the criteria of avoiding analytic functions and Oracle-specific features, but not the one about using only plain, simple SQL features.

  • Alert about the loading time & Restrict the number of the rows retrieved

    Hi everybody, maybe the question is stupid, but I didn't find yet an answer...
    I'm using BIP 10.1.3.4.1
    Because I have many reports with a huge amount of data to display (in HTML format) and customers once clicked on "View" have to wait a lot of time, they asked me if there is the possibility to do the following things:
    1. restrict the number of the rows retrieved (this for each report); this request has to be dynamic (different rows' number for each report and for each user); so, I can't modify the query into the data template in order to retrieve a fixed number of rows;
    2. show an alert who says for example " The data loading will take 5 minutes. Do you want to proceed ? YES - NO" This to inform the users how much time they have to wait if they click on Yes.
    I checked under the Administrator TAB...but I didn't find nothing "native" about the two questions above.....
    So, I ask you if there is a way to activate these features (if they exist "native") or a workaround to implement what I described above.
    Any help will be appreciated.
    Thanks in advance
    Alex

    Hi Vetsrini, thanks for your answer.....but what does it mean ? There are no solutions for my requests ? I remember that Discoverer had the possibility to have an alert as I would like to have with BI Publisher and there was the possibility to choose how many rows it was required from the customer....Is it possible that with BIP is not applicable ?
    Have a good day
    Alex

  • How to get rank within the row in SQL

    I have an a key orderid and 4 other columns with orderdate&time in (16/12/2011 16:15:24 format) within a table.
    the orderid has an average of 1million rows every week hence could not do this in excel for a 15 day period .
    ORderid.........: mail........................................ : telephone ............................:online ........................................ store.......................... Agency
    A3456...........15/12/2011 16:15:24 ............... 16/12/2011 14:12:01.............16/12/2011 16:14:00..........17/12/2011 11:22:55 ............12/12/2011 22:20:30
    B678
    C555
    i want to create a new table which ranks each row according to the max orderdate and time say in another table
    i want to capture the rank
    KEY.......Mail............Tel............online.........store..........Agency
    A3456.....4 ...............3...............2...............1............... 5
    Is there any way either within the same table or in other table i wiould be able to get the rank based on the rows in SQL.
    thnks
    Edited by: UOOLK on 29-Dec-2011 06:46

    Something like this I think:
    create new_order_table as
      select order_id
            ,rank() over (order by mail desc) mail
            ,rank() over (order by telephone desc) telephone
            ,rank() over (order by online desc) online
            ,rank() over (order by store desc) store
            ,rank() over (order by agency desc) agency
        from old_order_table;Assuming you want the most recent date to be ranked number 1. If you want number 1 to be the oldest then remove all the 'desc's from the order by clauses.

  • Ordering datagrid rows by dragging rows

    Hi all,
    I have a normal dg which is pulling data from MySQL db and
    i'm trying
    to figure out the best way to allow users to drag the rows to
    re-order
    as per however they may want it..
    This is what I thought buy some feedback would be great!
    1. Add 'order' column to sql db
    2. Set inital order for each row
    3. sort by order desc when pulling db into dg
    4. Create function to:
    a. when a user drops a row into desired position make each
    rows
    order = each rows index
    b. update mysql db when all changes are complete
    I also thought, maybe remember oldOrder val, + 1 to each
    order value
    from point of insertion until order = oldOrder??
    Obviously this method has issues when the # of rows grows..
    so thats
    why I would love some help with this! there must be a better
    way :)
    Thanks in advance!
    Matt (OzFlex Adobe User Group - Melbourne)

    Hi all,
    I have a normal dg which is pulling data from MySQL db and
    i'm trying
    to figure out the best way to allow users to drag the rows to
    re-order
    as per however they may want it..
    This is what I thought buy some feedback would be great!
    1. Add 'order' column to sql db
    2. Set inital order for each row
    3. sort by order desc when pulling db into dg
    4. Create function to:
    a. when a user drops a row into desired position make each
    rows
    order = each rows index
    b. update mysql db when all changes are complete
    I also thought, maybe remember oldOrder val, + 1 to each
    order value
    from point of insertion until order = oldOrder??
    Obviously this method has issues when the # of rows grows..
    so thats
    why I would love some help with this! there must be a better
    way :)
    Thanks in advance!
    Matt (OzFlex Adobe User Group - Melbourne)

  • Combining multiple rows to singe row thru SQL Stmt

    Hello,
    I am trying to combine values returned from multiple row into one row,
    thru inner/outer sql or any optimal way.
    In the example i would like to have First name, Last name, email and phone to be
    returned as a single row.
    create table TEMP_AAAAA
      FIRST_NAME VARCHAR2(25),
      LAST_NAME  VARCHAR2(25),
      CON_METHOD VARCHAR2(25),
      CON_VALUE  VARCHAR2(25)
    INSERT INTO TEMP_AAAAA VALUES('TOM','MAC','EMAIL','[email protected]');
    INSERT INTO TEMP_AAAAA VALUES('TOM','MAC','PHONE','12345');Any suggestion in doing it thru sql stmt.
    I have done this thru pl/sql, wondering if this could be achieve thru single SQL Stmt
    DECLARE
    v_FIRST_NAME  VARCHAR2(25);
    v_SECOND_NAME VARCHAR2(25);
    v_EMAIL       VARCHAR2(25);
    v_PHONE       VARCHAR2(25);
    BEGIN
    v_FIRST_NAME := NULL;
    v_SECOND_NAME := NULL;
    v_EMAIL := NULL;
    v_PHONE := NULL;
    FOR IMPL_CUR IN(SELECT * FROM TEMP_AAAAA ORDER BY CON_METHOD DESC)
    LOOP
            IF v_FIRST_NAME IS NULL
            THEN
               v_FIRST_NAME := IMPL_CUR.FIRST_NAME;
            END IF;
            IF v_SECOND_NAME IS NULL
            THEN
               v_SECOND_NAME := IMPL_CUR.LAST_NAME;
            END IF;  
            IF v_PHONE IS NULL AND IMPL_CUR.CON_METHOD = 'PHONE'
            THEN
               v_PHONE := IMPL_CUR.CON_VALUE;
            END IF;
            IF v_FIRST_NAME = IMPL_CUR.FIRST_NAME AND
               v_SECOND_NAME = IMPL_CUR.LAST_NAME AND
               length(v_PHONE) > 0
            THEN
              IF v_EMAIL IS NULL AND IMPL_CUR.CON_METHOD = 'EMAIL'
              THEN
                 v_EMAIL := IMPL_CUR.CON_VALUE;
                 EXIT;
              END IF;       
            END IF;
    END LOOP;
             DBMS_OUTPUT.put_line('firstName...:' || v_FIRST_NAME);    
             DBMS_OUTPUT.put_line('lastName....:' || v_SECOND_NAME);    
             DBMS_OUTPUT.put_line('PHONE.......:' || v_PHONE);
             DBMS_OUTPUT.put_line('EMAIL.......:' || v_EMAIL);
    END;

    Hi Ludy,
    Following query should work -
    P.S. - I have added records for one more person with first name as 'TOM1' and last name as 'MAC1' for testing purpose. Given inserts for these 2 records as well.
    Connected to Oracle Database 11g Release 11.2.0.1.0
    SQL>
    SQL> INSERT INTO TEMP_AAAAA VALUES('TOM1','MAC1','EMAIL','[email protected]');
    1 row inserted
    SQL> INSERT INTO TEMP_AAAAA VALUES('TOM1','MAC1','PHONE','12345');
    1 row inserted
    SQL>
    SQL>
    SQL> SELECT t.first_name
      2        ,t.last_name
      3        ,MAX(decode(t.con_method, 'PHONE', t.con_value, NULL)) phone
      4        ,MAX(decode(t.con_method, 'EMAIL', t.con_value, NULL)) email
      5    FROM temp_aaaaa t
      6   GROUP BY t.first_name
      7           ,t.last_name
      8  /
    FIRST_NAME     LAST_NAME   PHONE   EMAIL
    TOM            MAC         12345   [email protected]
    TOM1           MAC1        12345   [email protected]
    SQL> Hope this helps.
    Cheers,
    - Anirudha
    Edited by: Anirudha Dhopate on Nov 10, 2011 9:12 PM

  • How to get the last transaction in a row in SQL Developer?

    What syntax would I use to get the last transaction of a row in SQL developer?
    The way I have my query set-up currently it is not returning the correct data, here is my current syntax:
    select ssn, max(tran_id), chng_type,tran_id
    from pda_tran
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type,tran_id;
    It returns a 'C' chng_type but it is not the last one. when I query on this ssn this is what I get:
    ssn tran_id chng_type
    xxx-xxx-0011 001 A
    xxx-xxx-0011 002 E
    xxx-xxx-0011 003 C
    xxx-xxx-0011 004 S
    xxx-xxx-0011 005 C
    xxx-xxx-0011 006 T
    I only want to return the ssn's with a last transaction chng_type of 'C'. How can I get the correct information returned. Please advise.

    From what I see and read... there is one to many group by
    You wrote
    select ssn, max(tran_id), chng_type,tran_id
    from pda_tran
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type,tran_id;
    If you want the max(tran_id), remove it from the "group by"
    select ssn, chng_type, max(tran_id)
    FROM
    (SELECT 'xxx-xxx-0011' ssn, '001' tran_id, 'A' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '002' tran_id, 'E' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '003' tran_id, 'C' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '004' tran_id, 'S' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '005' tran_id, 'C' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '006'tran_id, 'T' chng_type FROM DUAL )
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type;

  • Failed to Retrieve SQL

    Hi,
    Using STANDARD REPORT CREATION WIZARD, I connected to UNIVERSES Data Sources and RUN a querry in BUSINESS OBJECTS QUERY PANEL,i am getting ERROR Message "Failed to Retrieve SQL".What would be the causes?
    Thanks,
    Sandeep

    Hi,
    try this link, [Click HEre|http://www.forumtopics.com/busobj/viewtopic.php?t=40450&sid=14981ec8c36d528ba129eedb58fe2e18]
    Regards,
    Clint

  • Ordering of rows are showing difference when migration db from 9.2.0.8.0-32bits(windows 3) to 10.2.0.5.0 - 64bit(windows 8)?

    Dears,
    After migration(via export/import), we are facing ordering of rows are mis-match  in these two databases.
    the following same query I am running on the these two databases. but different output. output are below.
    [CODE]
    SELECT ROWNUM AS RowNo, TBL1.*
      FROM (    SELECT COUNT (PG_ID) AS TotalCount,
                     PG_DESC AS PageDescription,
                     CURR_EPR_QUEUE AS CurrentQueue,
                     PG_NME AS PageName,
                     QUEUE_TYP_CDE AS QueueTypeCode,
                     PG_ID AS PageID
                FROM SASV_TB_CNT_APPL_JUDG_2----this is a view
               WHERE (CURR_EPR_QUEUE = 'test' AND QUEUE_TYP_CDE = '01')
                     OR (    JUD_RACIF_ID = 'test'
                         AND CMPLTD_IND = '0'
                         AND DSPLY_IND = '1')
                        AND TOTAL_CNT > 0
            GROUP BY PG_ID,
                     PG_NME,
                     PG_DESC,
                     CURR_EPR_QUEUE,
                     QUEUE_TYP_CDE            
                      ) TBL1
    [/CODE]
    output- from
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    TNS for 32-bit Windows: Version 9.2.0.8.0 - Production
    1
    7
    Other Documents(Hearing)
    askinj
    HG01_Other_Documents
    1
    HG01-TB02
    2
    3
    Pending Award
    askinj
    HG01_Pending_Order
    1
    HG01-TB05
    3
    19
    Motion(ADR)
    askinj
    MD01_Motion
    1
    MD01-TB01
    4
    5
    Other Documents(ADR)
    askinj
    MD02_Other_Documents
    1
    MD01-TB02
    5
    1
    Scheduling(ADR)
    askinj
    MD01_Scheduling
    1
    MD01-TB03
    6
    8
    Mediations
    askinj
    MD01_Mediations
    1
    MD01-TB04
    output from--
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
    1
    3
      Pending Award
    askinj
    HG01_Pending_Order
    1
    HG01-TB05
    2
    7
      Other   Documents(Hearing)
    askinj
    HG01_Other_Documents
    1
    HG01-TB02
    3
    8
      Mediations
    askinj
    MD01_Mediations
    1
    MD01-TB04
    4
    5
    Other Documents(ADR)
    askinj
    MD02_Other_Documents
    1
    MD01-TB02
    5
    1
    Scheduling(ADR)
    askinj
    MD01_Scheduling
    1
    MD01-TB03
    6
    19
    Motion(ADR)
    askinj
    MD01_Motion
    1
    MD01-TB01
    the views query is below
    SASV_TB_CNT_APPL_JUDG_2
    [code]
    (SELECT spm.PG_ID,
               spm.PG_NME,
               spm.PG_DESC,
               DECODE (TAJD.ABS_IND, 1, GUEST_JUD_ID, JUDG_ID) CURR_EPR_QUEUE,
               QUEUE_TYP_CDE,
               1 "TOTAL_CNT",
               DECODE (TAJD.ABS_IND, 1, GUEST_JUD_ID, JUDG_ID) JUD_RACIF_ID,
               CMLTD_IND CMPLTD_IND,
               NULL DSPLY_IND
          FROM SA_PG_MSTR SPM, TMST_APPEAL_JUDGE_DETAIL TAJD, SA_WRK_ITM SWI
         WHERE     SWI.WRK_ITM_ID = TAJD.WRK_ITM_ID
               AND swi.tb_pg_id = spm.pg_id
               AND SWI.CURR_EPR_QUEUE = 'AppellateCommonJudgeUser'
               AND CMLTD_IND = '0'
               AND tajd.LEAD_JUD_IND != '3'
        UNION ALL
        SELECT spm.PG_ID,
               spm.PG_NME,
               spm.PG_DESC,
               CURR_EPR_QUEUE,
               QUEUE_TYP_CDE,
               1 "TOTAL_CNT",
               CURR_EPR_QUEUE judg_racif_id,
               '0' CMPLTD_IND,
               NULL DSPLY_IND
          FROM SA_PG_MSTR spm, SA_WRK_ITM SWI
         WHERE SCCS_IND = '1' AND SWI.ACTIVE = '1' AND spm.pg_id = swi.tb_pg_id
        UNION ALL
        SELECT spm.PG_ID,
               spm.PG_NME,
               spm.PG_DESC,
               CURR_EPR_QUEUE,
               QUEUE_TYP_CDE,
               1 "TOTAL_CNT",
               JUD_RACIF_ID,
               CMPLTD_IND,
               DSPLY_IND
          FROM ST_WRK_ITM_JUD_DTL SWIJD, SA_WRK_ITM SWI, SA_PG_MSTR spm
         WHERE     SWI.WRK_ITM_ID = SWIJD.WRK_ITM_ID
               AND swi.tb_pg_id = spm.pg_id
               AND swi.queue_typ_cde IN ('01', '05')
               AND swi.dup_ind <> 1);
    [code]
    parameters in 9i are belows
    [code]
    aq_tm_processes    1
    background_dump_dest    D:\oracle\admin\TEST\bdump
    compatible    9.2.0.0.0
    cursor_sharing    similar
    db_block_size    8192
    db_cache_size    947912704
    db_domain
    db_file_multiblock_read_count    16
    db_keep_cache_size    167772160
    db_name    TEST
    fast_start_mttr_target    300
    hash_area_size    1073741824
    hash_join_enabled    TRUE
    instance_name    TEST
    java_pool_size    67108864
    job_queue_processes    10
    large_pool_size    109051904
    local_listener    (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.51)(PORT=1521))
    log_archive_format    %t_%s.dbf
    log_archive_start    TRUE
    log_buffer    26214400
    open_cursors    700
    optimizer_index_caching    80
    optimizer_index_cost_adj    20
    optimizer_mode    FIRST_ROWS
    pga_aggregate_target    1468006400
    processes    800
    query_rewrite_enabled    TRUE
    remote_login_passwordfile    EXCLUSIVE
    session_cached_cursors    400
    sga_max_size    2149134244
    shared_pool_size    788529152
    sort_area_size    1073741824
    star_transformation_enabled    FALSE
    timed_statistics    TRUE
    undo_management    AUTO
    undo_retention    10800
    undo_tablespace    UNDOTBS1
    utl_file_dir    H:\ICMS_TO_GO
    workarea_size_policy    AUTO
    [code]
    parameters in 10 are belows
    [code]
    aq_tm_processes    1
    compatible    10.2.0.5.0
    db_block_size    8192
    db_domain
    db_file_multiblock_read_count    16
    db_name    TEST
    db_recovery_file_dest    C:\oracle/flash_recovery_area
    db_recovery_file_dest_size    171798691840
    dispatchers    (PROTOCOL=TCP) (SERVICE=TESTXDB)
    job_queue_processes    10
    log_archive_format    ARC%S_%R.%T
    open_cursors    800
    open_links    10
    open_links_per_instance    10
    pga_aggregate_target    3984588800
    processes    1200
    recyclebin    OFF
    remote_login_passwordfile    EXCLUSIVE
    session_cached_cursors    400
    sessions    1325
    sga_max_size    10485760000
    sga_target    10485760000
    undo_management    AUTO
    undo_tablespace    UNDOTBS1
    utl_file_dir    H:\ICMS_TO_GO
    optimizer_dynamic_sampling    2
    optimizer_features_enable    10.2.0.5
    optimizer_index_caching    80
    optimizer_index_cost_adj    20
    optimizer_mode    FIRST_ROWS
    optimizer_secure_view_merging    FALSE
    plsql_optimize_level    2
    [code]
    where can we look into for this issue? actually we need rows will be the same ordering as it was in 9i.
    we are facing this problem in lot of queries, this is a sample one.
    Regards
    Halim

    Hi Jgarry,
    why do you need a particular physical order?
    Actually i don't know the .net application behave or code yet . but after migration, I am facing this issue.
    one more thing we changed the server machine so Is there any registry parameter (in windows) related to this. Have you any idea.
    the application is running since 8 years and I think nobody can rely on implicit data distribution arising from how the data is entered to develop a application.
    Hi Hoek,
    According to Oracle White Paper(page 17), If I change below parameter. Is there any hope to get same order.
    "After you upgrade to Oracle Database 10g, if you
    wanted to revert back to 9.2 optimizer behavior you can set
    OPTIMIZER_FEATURES_ENABLE = 9.2.0 "
    Regards
    Halim

  • Restore deleted rows in sql server 2008

    Hi,
    I have problem, I used import and export wizard in sql server 2008, and select wrong database in source data and wrong database in destination data (i Reflect databases) and  in editing mapping i make check for delete rows in destination table. 
    the step final complete and  i lost my data and i don't have backup
    how i can restore my data

    its not a straight forward activity if you don't have backups, first thing you need to do is to create proper maintenance plan for you databases. You can refer below links which could give some clue about your probles.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/86befdbe-9806-4d96-9e9f-ead753d0fc20/recover-deleted-rows-from-sql-server-database?forum=transactsql
    http://sqlserver2000.databases.aspfaq.com/how-do-i-recover-data-from-sql-server-s-log-files.html
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    Praveen Dsa | MCITP - Database Administrator 2008 |
    My Blog | My Page

  • Restricting users ability to modified Max Rows Retrieved

    Hi
    In Web Intelligence Rich Client how can I restrict a users ability to change the Max Rows Retrieved in a query.
    Currently we use Desktop Intelligence and restrict max rows retrieved in the universe, but I note this can be overwritten when by the user in Webi Rich Client at the query creation stage.
    SAP documentation indicates that a restriction can be applied in the security profile via the CMC but I'm unable to find this.
    Any help would be appreciated.
    Cheers
    Sean

    Any info would be helpful at this stage.  Thanks

  • How to retrieve SQL statement in the CR 2008

    I'm using Crystal Reports 2008 in MS Visual Studio 2008, how can i retrieve SQL statement from *.rpt file, i have tried this code, but it doesn't work:
    ReportDocument rdReport = new ReportDocument();
    rdReport.Load("Reports/EmployeeTest.rpt", OpenReportMethod.OpenReportByTempCopy);
    CrystalDecisions.ReportAppServer.Controllers.RowsetController rsController;
    CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rdClient = rdReport.ReportClientDocument; // on this line it throws an exception "The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."
    CrystalDecisions.ReportAppServer.DataDefModel.ISCRGroupPath rdGroupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
    string temp;
    string sql;
    rsController = rdClient.RowsetController;
    sql = rsController.GetSQLStatement(rdGroupPath, out temp);
    maybe i'm doing something wrong ?
    thanks

    Hello Ludek,
    when I try to get the report from the session I got an error like this (I am using State Server Session mode i.e out proc in my application)
    ReportClientDocument     'reportDocument.ReportClientDocument' threw an exception of type 'System.InvalidOperationException'     CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument {System.InvalidOperationException}
    +base     {"The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."}     System.SystemException {System.InvalidOperationException}
    StackTrace     "   at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ReportClientDocument()"     string
    so is it the problem of not opened with RAS. Does installation of RAS solves the problem, If so Is it a free-ware or needs to be purchased.
    Ashok

  • Unknown Database Connector Error   Details: "Failed to retrieve SQL Error"

    Hi
    Getting "Failed to retrieve SQL Error" while trying to refresh the Crystal report.
    Unable to create a new report also
    This is my ERROR MESSAGE
    "Unknown Database Connector Error   Details: "Failed to retrieve SQL Error"
    Previous Error: Query generated multiple SQL statements.However multiple SQL is not supported in crystal reports query panel"
    Any Suggestion.

    Hi,
    Please note that any query that generates multiple SQL statements is not supported in the Query Panel in Crystal Reports.
    I guess this Universe is generating multiple SQLs and hence the error.
    I found this option while I was searching for something else: Could you try turning off the "Multiple SQL statement for each measure" in the Universe parameters and see if it works?
    Also, here's the Universe Support Guide, although old, it is still applicable:
    http://www.sdn.sap.com/irj/boc/go/portal/prtroot/docs/library/uuid/20984c2b-17f1-2b10-1091-d18977f7cd8f?QuickLink=index&overridelayout=true
    -Abhilash

Maybe you are looking for

  • PSE12 install: Error 1335, Data1.cab corrupt

    PSE12 install: Error 1335, Data1.cab corrupt Install from online purchase with download, all remedies are relevant to CD-ROM?! How do I get my money back?

  • DVD not working.

    I burned a DVD I made that had videos from iMovie but the DVD is not working. The DVD is in 16:9 and in a 7.0 theme. The iMovies are 960x540 (and 1280x720 which didn't work either.) I burned one DVD with only 960x540 (.mov) movies and another DVD wit

  • How do I get iTunes to show the file path for music

    I am trying to get iTunes to show me where songs are located on my computer,  Hoiw do I get this to show up in iTunes?  Thank you

  • Classnotfoundexception eventhough the class is inside jar

    Hi guys, I encountered weird problem where sometimes it throws classnotfoundexception eventhough the class is inside jar. I terminate the program and start it again then it works fine. I compiled the jar using ant      <target name="compile" depends=

  • Error while importing HCM_Staging_Area_Identity Store

    Hi * During import of "HCM_Staging_Area_Identity Store.mcc" I receive the following Error: Could not update identity center with attribute '333\MX_ENTRYTYPE' I realized that the Import-File has a Schema-version 517 while the Target IdentityCenter has