Selecting specific number of records

Hellow
How can we query certain number of records from table. For example if a table has thousands of records and i wish to query
1. first 500 records
2. Records between 500 and 1000 or between <anynumber> to <any number>
3. Records less than <some number>
I cannot perform the same operation from a primary key as it is not in serial.
I tried to use ROWNUM, but i cannot use this when i want to select rows less than 100 or rows between 100 and 200...
How can i accomplish this
Regards
Sunny

1. first 500 records
select *
from ( YOUR_QUERY_GOES_HERE -- including the order by )
where rownum <= 500Another way using analytical functions can be found in the documentation Top N Ranking
2. Records between 500 and 1000 or between
<anynumber> to <any number>
select *
  from ( select a.*, rownum rnum
           from ( YOUR_QUERY_GOES_HERE -- including the order by ) a
          where rownum <= MAX_ROWS )
where rnum >= MIN_ROWShttp://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:127412348064
3. Records less than <some number>
select *
from my_table
where my_column <   <some number>

Similar Messages

  • Select specific number of rows

    i'm listing all data entries in a database.
    for that i want to select the 1st ten entires, then the next ten and so on ordered
    by date_column.
    how can i do that? is it possible with rownum?
    in mysql/php i did it with limit
    $query = "select * from article where parent_id=0 order by date desc, time desc limit $select, 10";
    please email me.
    thanks for help
    chris

    but what about rownum if i want the
    records from 10-20?
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Chen Zhao ([email protected]):
    If you are using Oracle 8i, you can use ROWNUM to specify the specific number of records. You can see the ROWNUM by querying:
    SELECT *
    FROM (SELECT column_name FROM table_name ORDER BY column_name)
    WHERE ROWNUM<10
    CHEN<HR></BLOCKQUOTE>
    null

  • Select specific no. of records?

    hi all!
    i want to select specific no. of records from a table e.t.c KNA1.
    means i have given the filed on screen to select how much records u want to select i.e user can give any no. and so that no of records should be picked.
    how it is possible.

    Hi,
    I am assuming you have a selection screen S_KNA1.
    Select-options : S_KNA1 for KNA1-KUNNR.
    Select *
    from KNA1 into table itab
    where KUNNR in S_KNA1.
    Hope This Help.
    Vikas

  • Capability of inserting a specific number or records ...

    Hi ,
    Is there any way to permit the end-user enter a specific number or records in a multi-record block..... according to the number of fetched records in another block...????
    I assume that the trigger when-create-record can do that ... Are there any other solutions...???
    Thanks ,
    Simon

    ..Or,
    this is for single block ,but i believe works also for multirecord
    A parameter for defining the limit for the number of records the user can
    query.
    1. Define a parameter, :max_record, which is the limit for the number of records
    the user can enter. Make sure to define this parameter as numeric
    and provide a default value.
    2. For a form with a single block, create the following triggers at block level:
    a. Attach the following PL/SQL block to a KEY-CREREC trigger to create a
    record only when :system.cursor_record is less than :max_record.
    DECLARE
    a NUMBER;
    b NUMBER;
    BEGIN
    a := :system.cursor_record;
    LAST_RECORD;
    b := :system.cursor_record;
    IF b >= :parameter.max_record THEN
    GO_RECORD(a);
    MESSAGE('max record exceeded - create rec III');
    RAISE FORM_TRIGGER_FAILURE;
    END IF;
    GO_RECORD(a);
    IF :system.cursor_record < :parameter.max_record THEN
    CREATE_RECORD;
    ELSE
    MESSAGE('max record exceeded - create rec ');
    RAISE FORM_TRIGGER_FAILURE;
    END IF;
    END;
    b. To navigate to the next record when :system.cursor_record is
    less than the :max_record, create a KEY-DOWN trigger.
    IF :system.cursor_record < :parameter.max_record THEN
    DOWN;
    ELSE
    MESSAGE('max records key-down');
    END IF;

  • Lock specific number of records using ENQUEUE & DEQUEUE

    Hi,
    Is it possible to lock a group of records in R/3?
    My requirement is to update a set of records in VBAP table. I'm not using a BAPI here. Instead, I use a direct UPDATE.
    In this case, i know i can lock individual records by passing VBELN and POSNR. But what if i have to lock 10 records?
    Is this possible in any way?
    Thanks in advance.
    The current solution is:
    1) LOOP at ITAB
    2) LOCK each entry
    3) UPDATE VBAP for that entry
    4) UNLOCK the entry
    5) Endloop
    I thought this solution might work: (Assume 10 records are present in ITAB)
    1) LOOP at ITAB (Lock all 10 entries)
    2) LOCK that entry
    3) ENDLOOP
    4) UPDATE VBAP from ITAB (Updates all 10 entries in one databae access)
    5) LOOP at ITAB(Unlock all 10 entries)
    6) UNLOCK that entry
    7) ENDLOOP
    Any help will be appreciated.
    Tabraiz.

    Hello,
    Both of your solutions will work.
    With solution 1 there will always be only 1 enqueue object created, because you always enqueue, perform the update and dequeue.
    This means that in SM12 you will only see 1 enqueue entry on your user ID at the same time when your program runs.
    Solution 2 is also possible but there you will have different enqueue objects that will be created, because you enqueue everything, then perform the updates and then dequeue everything.
    In SM12 (lock entries) this will result in more enqueue records on your user ID the time your program runs.
    You have to pay attention that lock entries (SM12) are stored in a queue that is limited, so make sure with solution 2 that you don't overflow the enqueue queue ! ! !
    Via tcode RZ11 you can check parameter enque/table_size (Size of lock table).
    Check the parameter value but also its documentation and you will understand why you should limit the number of open lock records.
    Success.
    Wim Van den Wyngaert

  • Reg: Find Duplicate Records and select max number of record in Table

    Hi Guys,
         This is Nagendra, India.
    my table structure is
    id  name  tempid  temptime
    1  xxx     123        date
    1 yyy       128       date
    1 sdd     173       date
    14 ree    184      date
    14 fded   189     date
    This is Table Structure, totally 15000+ records is there.
    My Requirement is showing id and max(tempId) value.
    id  name  tempid  temptime
    1   sdd    173      date
    14  fded   189     date
    Like that, I want to show all record(after hiding duplicate values ) like that Could you please solve this issue.
    With Regards,
    Nagendra

    ; WITH numbering AS (
        SELECT id, name, tempid, temptime,
               rowno = row_number() OVER(PARTITION BY id ORDER BY tempid DESC)
        FROM  tbl
    SELECT id, name, tempid, temptime
    FROM   numbering
    WHERE  rowno = 1
    The WITH thing defines a Common Table Expression which is a locally defined view which only exists for this query. The row_number function numbers the rows, re-starting on 1 for every id, and they are numbering in falling tempid order. Thus, by
    selecting all rows from the CTE with rono = 1, we get the row with the highest tempid for each id.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Maximum number of records to 'BAPI_PIRSRVAPS_SAVEMULTI'

    Hi All ,
    Could anybody tell me maximum number of records that can be passed to BAPI
    BAPI_PIRSRVAPS_SAVEMULTI.
    This BAPI is used for forecast upload to SNP planning area (which can be seen in product view: /sapapo/rrp3).
    Win full points for the resolution...
    Thanks in advance...
    Chandan Dubey

    Hi Chandan - There is no simple answer to this question.
    BAPI_PIRSRVAPS_SAVEMULTI has a built in package (number of records to process) counter which sends packets of data to livecache for creating data. By default this BAPI will process all records at once but there is a BADI in this BAPI that allows you to set the package size as well as many other things. The performance will depend upon things like your system,  environment and volume of data. There are 2 limitations in 1) the prereading (retrieval of matlocids, matids, locids, pegids, etc.) which happens prior to the livecache call and 2) the livecache call itself. The prereading can cause a memory overload but that is less likely to happen compared to a livecache problem. The proceduress that call livecache can run out of more likel than the ABAP tables and cause the program to dump as well and the dump may be hard to understand.
    What I have done with many programs is to add a wrapper around a livecache BAPI (or FM) call and use my own counter to send blocks or packets of data to the BAPI. For example loop through records in a program and call the BAPI for every 1000 records accumulating the return info in an internal table. The number of records in each packet or block is driven by a parameter on a selection screen or value in a ztable so the number can be tested and adjusted as needed. The reaction of livecache BAPIs will differ from system due to things such as hardware configuration and volume of data.
    If you do not code to call the BAPI as I have described above, place code in the BADI to set the packet size or limit the number of records being input some other way, then you are taking a risk that one day a specific number of records will cause a dump in this BAPI.
    I would think you would be safe with 500-1000 records but you should really test in your system and consider the options for packeting the number of records.
    Andy

  • Optimal number of records to fetch from Forte Cursor

    Hello everybody:
    I 'd like to ask a very important question.
    I opened Forte cursor with approx 1.2 million records, and now I am trying
    to figure out the number of records per fetch to obtain
    the acceptable performance.
    To my surprise, fetching 100 records at once gave me approx 15 percent
    performance gain only in comparsion
    with fetching records each by each.
    I haven't found significant difference in performance fetching 100, 500 or
    10.000 records at once.In the same time, fetching 20.000
    records at once make a performance approx 20% worse( this fact I cannot
    explain).
    Does anybody have any experience in how to improve performance fetching from
    Forte cursor with big number of rows ?
    Thank you in advance
    Genady Yoffe
    Software Engineer
    Descartes Systems Group Inc
    Waterloo On
    Canada

    You can do it by writing code in start routine of your transformations.
    1.If you have any specific criteria for filtering go with that and delete unwanted records.
    2. If you want to load specific number of records based on count, then in start routine of the transformations loop through source package records by keeping a counter till you reach your desired count and copy those records into an internal table.
    Delete records in the source package then assign the records stored in internal table to source package.

  • To get  the number of record from cmp

    how can i get the specific number of record (25 records) from cmp using weblogic8?
    anybody know pls tell.

    http://java.sun.com/j2se/1.4.1/docs/api/java/io/File.html

  • Select  a specific  number of rows in query

    How can a specific number of rows be selected in a query? For example, a query retrieves 30,000 records and I want to retrieve the output by groups of 5,000. I want the query to retrieve the first 5,000 records, then the next 5,000 records etc. I tried rownum but that does not work.
    Thanks,
    PANY

    Not AGAIN. Please...........
    Do you know how to Google? Search forum?
    Why do you ask this boring FAQ AGAIN?
    Sybrand Bakker
    Senior Oracle DBA
    Experts: Those who know how to search.

  • Which system field returns the number of records returned after a select?

    Which system field returns the number of records returned after a select?
    a) sy-index
    b) sy-recno
    c) sy-lncnt
    d) sy-dbcnt
    e) sy-tabix

    Hi,
       SY-DBCNT
    Regards,
    Prashant

  • How to get number of records in all user tables in one select

    Please advise how to retrieve the number of records in all user tables in one select. I would likt to extract the data to excel file.
    Many thanks,
    Andrew

    You could always analyze the tables:
    declare
    begin
      for X in (select owner, table_name from all_tables
                 minus
                select owner, table_name from all_external_tables) LOOP
          dbms_stats.Gather_Table_Stats(X.Owner, X.Table_Name) ;
      end loop;
    end;
    /Then: Select Owner, Table_Name, Num_Rows from All_Tables ;

  • Number of records in cursor select statement

    hi all,
    with the cursor i am selecting set of select statement and writing into the .txt file.
    its working file, but it should not open the file if the cursor returns nothing.
    how to check for the number of records return by the select statement in the cursor.
    pls help me.
    Thanks..

    Hi,
    You can use a Cursor for loop (you'll not enter in the loop if the SELECT is retrieving no rows):
    begin
    for recs in(select * from whatever) loop
    null; -- Produce your file
    end loop;
    end;You can also use a bulk collect and check "yourcollection.count" attribute ... (but don't use it if you are processing a lot of records!)

  • Code to verify the number of records before selective deletion

    In order to archive some old data, I would like to do a selective deletion in the source cube after their transfer in the archive cube  by launching a program.
    I’ve seen in this forum that the name of the function module to do a selective deletion is RSDRD_SEL_DELETION.
    Nevertheless, I would like to check before if the <b>number of records</b> of the <b>archiving period</b> in my archive <b>cube</b> is the same as in my source cube.
    Who can help me to write the code to do this check with a selection of time? Thanks in advance

    Hi Domi,
    You can do it via the cintents tab in the management function of the infoprovider.
    There also is an selective deletion function button.

  • SELECT query & Database Table Difference in number of records

    Hi All,
    In program it’s selecting 3 records based on selection parameters whereas when i execute SE16 with same selection criteria gives 4 records.
    Please suggest when we will face these kind of issue
    Thanks,
    Spandana

    SELECT objnr wlges
    FROM bpge
    INTO TABLE t_bpge
    FOR ALL ENTRIES IN t_prps
    WHERE lednr  EQ c_0002
    AND      objnr  EQ t_prps-objnr
    AND      wrttp  EQ c_41.
    Here t_prps-objnr has the following values
    PR00473170
    PR00397060
    PR00397061
    PR00397062
    PR00397063
    PR00397064
    PR00397065
    For this selection criteria there are 4 records in BPGE table where as the program is fetching only 3

Maybe you are looking for

  • How do I get a movie clip to follow the cursor?

    Hi guys, What I want: Is a simple action where I have my company logo in the middle of the screen and it follows the cursor (not over the whole screen but within invisible borders). What I use: I have Flash Pro CS5, code is Actionscript 3.0 and my co

  • SRM: Sendo PO via mail or print it to PDF

    Hello, I'm working on SRM 7.0 and I'm really new on it and in SAP. My first task is to configure the POs to be sent to suppliers' email or, in case there is no email available, print the PO in PDF. Can you please tell me what should I take into accou

  • Usage reports and analytics

    Hey everyone, just was curious to know what people were doing for analytics for their iTunesU site. Is anyone going above the weekly usage report, or doing anything unique that you might like to share? Thanks

  • Detonator R.I.P.

    nVidia has today introduced their new series of graphic drivers called "Forceware" v52.16 WHQL'd to replace the aged detonator series. Although benchmarking scores went down with the default driver settings game performance in most of the games i tes

  • UCCX 8.0 in test Lab

    Hello Folks, I'm going to install UCCX 8.0 in a test lab and I'm wondering what hardware other are using? I'm presuming that it needs ESXi4.0?  Do you have to use the full production specification of 2 x vCPU and 4GB RAM?  Or can you cut down the res