To get last 10 records

hi
suppose there are 50 records in a table
but i want last 10 records .how can we retrive them?
thanks in advance.......

It works fine. The only odd thing is the timestamp appears later and the message (alert) appears first. But this is much better.
Like this -
Current log# 2 seq# 7479 mem# 0: D:\TESTDB\ORADATA\DATAFILES\TESTDB\REDO02.LOG
Thread 1 advanced to log sequence 7479
Thu May 01 12:30:40 2008
ORA-00600: internal error code, arguments: [qkatab_10], [16], [79557], [], [], [], [], []
Errors in file d:\admin\testdb\udump\testdb_ora_2092.trc:
Thu May 01 11:35:21 2008
ORA-00600: internal error code, arguments: [qknltAllocate_10], [79557], [], [], [], [], [], []
Errors in file d:\admin\testdb\udump\testdb_ora_2092.trc:
Thu May 01 11:34:45 2008
WARNING: inbound connection timed out (ORA-3136)
Thu May 01 11:26:38 2008
Thank you all,
Sanju.

Similar Messages

  • Getting last record from mseg

    Hi,
    Can any one tell me how to get last record from any db(MSEG) table?
    reward guaranteed
    kaki

    Hello,
    Entries have no "natural order" within a database, apart from the primary key. If you need the "last entry" then you need to know what defines the last entry. If the last entry is the one with the highest year (MJAHR) the you could select it like this:
    data: ls_mseg type mseg.
    select * from mseg into ls_mseg.
        where bwart = 321
          and ebeln = 400000005
          and mjahr = ( select max( mjahr ) from mseg
                          where bwart = 321
                            and ebeln = 400000005 ).
    "process result in ls_mseg
    endselect.
    Note: This is a loop because there might be more than one matching entry.
    best regards
    Roland

  • How to get last Record ior Total rows in For Loop Cursor ?

    Hi Friends
    I would like to know , the last record in for loop cursor, i have the code in following format
    cursor c1 is
    select * from emp;
    begin
    for r1 in c1 loop
    v_total_rec := ? ( i would like to know total rows in the cursor , say for example if cursor has 10 rows, i want10 into this variable )
    v_count := v_count +1;
    dbms_output.put_line(r1.emp_name);
    end loop;
    end;
    Hope i am clear
    Any suggestions?
    Thanks
    Ravi

    Even though cursor loops are generally a Bad Idea ^tm^ as Dan says, here's an example of how you can get the information you wanted within the query itself...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    cursor c1 is
      3      select emp.*
      4            ,count(*) over (order by empno) as cnt
      5            ,count(*) over () as total_cnt
      6      from emp
      7      order by empno;
      8  begin
      9    for r1 in c1 loop
    10      dbms_output.put_line(r1.ename||' - row: '||r1.cnt||' of '||r1.total_cnt);
    11    end loop;
    12* end;
    SQL> /
    SMITH - row: 1 of 14
    ALLEN - row: 2 of 14
    WARD - row: 3 of 14
    JONES - row: 4 of 14
    MARTIN - row: 5 of 14
    BLAKE - row: 6 of 14
    CLARK - row: 7 of 14
    SCOTT - row: 8 of 14
    KING - row: 9 of 14
    TURNER - row: 10 of 14
    ADAMS - row: 11 of 14
    JAMES - row: 12 of 14
    FORD - row: 13 of 14
    MILLER - row: 14 of 14
    PL/SQL procedure successfully completed.
    SQL>

  • Formula to get last record entered for a specific code in a field

    I work at an inpatient facility where our patients experience several movement actions -- transfers from unit to unit, Leaves, return from leaves, and change in commitment status.  We collect all of these actions in one table.  For our census report we use a subreport to show the list of patients who are on leave.  The problem I am having is pulling the most current movement that was a leave if the last movement action code entered was a change in commitment status.  We really should not have put the change in commitment in this table as it is not a movement.  When a change in commitment occurs and the patient is on leave, they drop off my report because the last change was not a leave.  We have to enter the leave again so it is the last record entered to fix. 
    The table contains these fields:
    Doc_ID
    Parent_ID
    Folder_ID
    Effective Date
    From_Unit
    To_Unit
    Time_of_Change
    Leave_status_Code
    Move_Action_Code
    Commit_Status_Code
    The Move_Action_Code field contains these codes:
    L = Leave
    C = Change in Commitment Status
    B = Return From Leave
    I = Initial Admission
    D = Discharge
    R = Recommitment
    V = Unit to unit transfer
    A patient may have several leaves in the same admission (home visit, then back, etc.).  I need a formula to show only most current leave if they haven't returned from leave and need to totally ignore any change in commitment status.
    Thanks in advance to everyone for your help in this forum!

    Hi Jerri,
    To identify a patient, I assume it would be Folder_ID.  Create a group on this field.  Also create a group on Effective Date. 
    Hide the Detail section and the Group Headers for both of these.  You can also hide the Group Footer for Effective Date. 
    In the Group Footer for Folder_ID, drop in the Move_Action_Code and any other fields you want. 
    When you look at your report, this will show you the last Move_Action_Code for that patient. 
    If you can group your data properly, the Group header will always show the first record and the Group Footer will always show the last record. 
    Hope this helps,
    Brian

  • Get last record inserted

    Hi i am inserting into 2 tables. I am first inserting into
    client id. I then want to get that client id and insert it into the
    sale table.
    What is the easist way to get this.

    You have a couple options depending on your database.
    1. The best, in my opinion, is to wrap this functionality
    into a stored procedure that will handle the multiple inserts, then
    run that stored procedure inside a transaction (or include the
    transaction inside the stored procedure).
    2. Use the result object returned by cfquery on the first
    insert to get the ID of the new record from result_name.IDENTITYCOL
    (or whatever property is set for your database). Then use the ID
    value in a second cfquery for the sales table.
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_p-q_17.html#1102316
    What is your database product and version?

  • Getting   last record

    hi this is my table
    select * from emp0;
    NAME ID AGE SALARY DOJ
    karthik 101 25 260000 01-JAN-04
    mano 102 28 156000 08-FEB-04
    padhu 103 26 50000 05-MAR-05
    suresh 104 21 15000 01-JAN-05
    kumarn 105 24 16000 08-MAY-06
    sasmitha 107 4 1 11-FEB-06
    6 rows selected.
    how can i fetch last inserted row and last row in my table?tell me the query please,
    sorry for putting this in a new thread, i dnt know how to reply to the moderator in my post,that's why i am using new thread

    There isn't any easy way to do that. You can use a updt_timestamp column int he table and use a trigger for insertion. Or take a sequence primary key and find the max value. Or you can use the ROWID for this purpose. Like the one below.
    SQL>select * from emp where
      2  rowid = (select max(rowid) from emp)
      3  /
        EMPNO ENAME      JOB             MGR HIREDATE                 SAL      COMM    DEPTNO
         9999 ADAMS      CLERK          9999 12-JAN-83 00:00:00      7000                  20
    SQL>Cheers
    Sarma.

  • How to get the last record from the database

    I am using MS Access database and Swings as GUI. I want to get the last record of a particular column from the table and store it as a varaible.

    Hi
    To get Last record of resultset, you have pass some parameter in constructor of CreateStatement.In such case Resultset should be scrollable and Readonly
    Example
    objStatement=objCon.createStatement ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    mwwResultSet=cwwStatement.executeQuery(mwwSqlQuery);
    while(mwwResultSet.next())
    if(mwwResultSet.isLast())
    //Fetch the required column record.
    String abc=mwwResultSet.getString(1);
    I think this will work. Try it.
    bye

  • How to get last row and sum of all columns in one query

    Hi ,
    is there a way to get last record for a column and sum of all record for another column in the same query.
    Best Regards ,

    You should define your requirements properly for volunteers to help here..
    Your data is not good enough to provide you accurate solution. Reason being you dont have a proper column which differentiates between first and last entry.
    The solution becomes easy based on your desgin.
    I have introduced a grouping column called "id" and a time column called "time_of_insert" (only this way you can confidently say that you can differentiate between first and last (also a fool proof solution) --- you may optionally use sequence(instead of date though if you say you may end up inserting two rows at the same time, then probably sequence would be a better choice to differentiate rather than a timestamp field) etc...)
    With your sample data something like this can be done to achieve your desired result.
    WITH dataset AS
            (SELECT 1 id,10 used, 8 remain,systimestamp+1/24 time_of_insert FROM DUAL
             UNION ALL
             SELECT 1 id, 1, 7,systimestamp+2/24 FROM DUAL
             UNION ALL
             SELECT 1 id,2, 5,systimestamp+3/24 FROM DUAL
             UNION ALL
             SELECT 1 id,1, 0,systimestamp+4/24 FROM DUAL
             UNION ALL
             SELECT 1 id,0, 0,systimestamp+5/24 FROM DUAL
             UNION ALL
             SELECT 1 id,1, 4,systimestamp+6/24 FROM DUAL)
    SELECT *
      FROM (SELECT SUM (used) OVER () sum_all,
                   FIRST_VALUE (remain)
                      OVER (PARTITION BY id ORDER BY time_of_insert DESC)
                      last_row
              FROM dataset)
    WHERE ROWNUM = 1;
    Output:
    SUM_ALL       LAST_ROW
    15                  4
    Cheers,
    Manik.

  • Sql query - Selecting last recorded values for each date in specified period

    Hello,
    Can someone please help me with my problem.
    I'm trying to get last recorded balance for each day for specific box (1 or 2) in specified period of days from ms access database using ADOTool.
    I'm trying to get that information with SQL query but so far unsuccessfully...  
    My table looks like this:
    Table name: TestTable
    Date Time Location Box Balance
    20.10.2014. 06:00:00 1 1 345
    20.10.2014. 12:00:00 1 1 7356
    20.10.2014. 18:45:00 1 1 5678
    20.10.2014. 23:54:00 1 1 9845
    20.10.2014. 06:00:02 1 2 35
    20.10.2014. 12:00:04 1 2 756
    20.10.2014. 18:45:06 1 2 578
    20.10.2014. 23:54:10 1 2 845
    21.10.2014. 06:00:00 1 1 34
    21.10.2014. 12:05:03 1 1 5789
    21.10.2014. 15:00:34 1 1 1237
    21.10.2014. 06:00:00 1 2 374
    21.10.2014. 12:05:03 1 2 54789
    21.10.2014. 15:00:34 1 2 13237
    22.10.2014. 06:00:00 1 1 8562
    22.10.2014. 10:00:00 1 1 1234
    22.10.2014. 17:03:45 1 1 3415
    22.10.2014. 22:00:00 1 1 6742
    22.10.2014. 06:00:05 1 2 562
    22.10.2014. 10:00:16 1 2 123
    22.10.2014. 17:03:50 1 2 415
    22.10.2014. 22:00:10 1 2 642
    23.10.2014. 06:00:00 1 1 9876
    23.10.2014. 09:13:00 1 1 223
    23.10.2014. 13:50:17 1 1 7768
    23.10.2014. 19:47:40 1 1 3456
    23.10.2014. 21:30:00 1 1 789
    23.10.2014. 23:57:12 1 1 25
    23.10.2014. 06:00:07 1 2 976
    23.10.2014. 09:13:45 1 2 223
    23.10.2014. 13:50:40 1 2 78
    23.10.2014. 19:47:55 1 2 346
    23.10.2014. 21:30:03 1 2 89
    23.10.2014. 23:57:18 1 2 25
    24.10.2014. 06:00:55 1 1 346
    24.10.2014. 12:30:22 1 1 8329
    24.10.2014. 23:50:19 1 1 2225
    24.10.2014. 06:01:00 1 2 3546
    24.10.2014. 12:30:26 1 2 89
    24.10.2014. 23:51:10 1 2 25
    Let's say the period is 21.10.2014. - 23.10.2014. and I want to get last recorded balance for box 1. for each day. The result should look like this:
    Date Time Location Box Balance
    21.10.2014. 15:00:34 1 1 1237
    22.10.2014. 22:00:00 1 1 6742
    23.10.2014. 23:57:12 1 1 25
    So far I've managed to write a query that gives me balance for ONLY ONE date (date with highest time in whole table), but I need balance for EVERY date in specific period.
    My incorrect code (didn't manage to implement "BETWEEN" for dates...):
    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    Tnx!
    Solved!
    Go to Solution.

    For loop
    following query keep day (here 24 in below query) Variable from ( 1 to 28-29/30/31 as per month)
    SELECT TOP 1 TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM Test Table.
    WHERE  Time=(SELECT MAX(Time) FROM TestTable WHERE Location=1 AND Box=1 )
    AND DATE = "2014-10-24";
    PBP (CLAD)
    Labview 6.1 - 2014
    KUDOS ARE WELCOMED.
    If your problem get solved then mark as solution.

  • Compare 2 data sets and display the last record

    I have one record in first table and 2 records in second table.
    Ex:Table 1:
    A     100     200   0
    B     200     300   0
    Table 2:
    A      0        0     100
    A      0        0     500
    B      0        0     700
    In one final template I want to display like below with only 2 records like below.
    A      100    200    500
    B      200    300    700
    Anybody suggest me how to pick only last record if the count is greater than 1 in second table.

    not sure what are you trying to do
    if you want to join two table then sql is more useful IMHO
    Anybody suggest me how to pick only last record if the count is greater than 1 in second table.
    you can get last record by last() function
    <?for-each:SOMETAGorGROUP[position()=last()]?>

  • How to get the last record??

    Hi, I now have to get only the last record from one table
    from MS Access.
    I was looking for the useful method from API, however,
    I cannot get it.
    How to get only the last record from one table ???
    Please help, thanks.

    In RDBMS, row order is really not relavent by iteself. Meaning there is no such thing as 'last record' unless it's in the context of a column (e.g. timeStamp).
    Of course, rows are inserted and stored in some natural order, but you cannot assume they'll come back the same way in a 'Select *' as they were entered.
    So, if you mean last row as in last inserted row, I would add a timestamp field that's set at insert, or use a autonumber column. Either way, have a column that will always contain the highest number or newest timestamp, and then you can build your where clause from that.
    For instance, in Access, I have an autonumbered field called 'fred', with other columns. If I want the last record, I simply use the following:
    select * from atable where fred in (SELECT max(fred) AS Max FROM atable);
    the 'where in' clause will filter to only those records in the subsequent select statment, which of course is only one, the max of the column fred.
    bRi

  • How to get the last record of an internall table ....

    Hi All..
    i want to get the last record of an internal table itab, and i want the the value of the last record.

    Hi,
         Use describe statment.
    data: lv_line type i.
        Describe table itab lines lv_line.
        read table itab into wa_itab index lv_line.
    regards,
    Santosh Thorat

  • How to get the first and the last record of every month within a time range in sql

    I am trying to get the first record and the last record of each and every month in a given date range using sql. I have a sample code
    where i have just selected everything within the date range now i have to extract the first and the last records of each and every month.
    SELECT PurOrderNum,
    OrderDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'

    SELECT PurOrderNum,
    OrderDate
    FROM
    SELECT PurOrderNum,
    OrderDate,
    MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
    MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'
    )t
    WHERE OrderDate = MaxDate
    OR OrderDate = MinDate
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • SQL query to get last 6 months records neglect the current month

    Hi All;
    I need help with 
    sql query to get last 6 months records neglect the current month
    Any help much appreciated
    Thanks
    Pradnya07

    SELECT <> FROM tbl WHERE dt >=dateadd(month,-6,GETDATE())
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • SQL query to get last 10 records in the table?

    Hi,
    Can anyone tell me the SQL query to get last 10 records in the table?
    Thanks!!
    MCP

    Please, define what "last" means. Sets are unordered by definition, so if you want to retrieve rows from a table in a specific order you need to specify what that order is - e.g. by maintaining a value in a column (or a combination of columns) that you can use in the ORDER BY clause of the SELECT statement.
    If, for instance, you kept the time when the row was inserted in a special column (InsertedTime), you could use this in your query like this:
    select top (10)
      <column list>
      from <table or view>
      where <restriction(s)>
      order by InsertedTime desc;
    ML
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • How to get particular record in last

    Hi,
    I want query for if existing particular record whenever come as a last record.
    Ex,
    name
    s
    t
    h
    but t always comes last record. how to i get?
    Thanks,
    Dhamu.

    816776 wrote:
    Hi,
    I want query for if existing particular record whenever come as a last record.
    Ex,
    name
    s
    t
    h
    but t always comes last record. how to i get?
    Thanks,
    Dhamu.Your question makes no sense (and yes we can excuse the fact that English is not your first language).
    What determines if a record is "existing"? All the records exist, so there must be something else.
    For example if a record is determined as "existing" because it exists on another table you could left outer join to that table which then gives all the records from your first set of data and puts any that exist in the second set of data at the end in terms of ordering...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 's' as name from dual union all
      2             select 't' as name from dual union all
      3             select 'h' as name from dual)
      4  -- Records to compare against.
      5      ,t2 as (select 't' as name from dual)
      6  --
      7  -- END OF TEST DATA, JUST USE QUERY BELOW AGAINST YOUR OWN TABLE
      8  --
      9  select t.name
    10  from t left outer join t2 on (t.name = t2.name)
    11* order by t2.name nulls first, t.name
    SQL> /
    N
    h
    s
    t
    SQL>

Maybe you are looking for

  • How can I download something on my phone or iPad and it automatically is downloaded to the other

    I had noticed that every month my account was in negative and from my deposits it should not have been even close to overdraft. I started to really pay attention to account. I had not been checking very often cuz diagnosed with malignant melanoma and

  • Problem in BAPI_DOCUMENT_CHANGE2 with attachment

    Hi Friends, I am using the BAPI for updating the status from In work to Release in DMS wit attachment. While executing BAPI_DOCUMENT_CHANGE2 we are facing the problem. I attach a document in CV01N. I enter the details of the document in document file

  • Function works fine in 8.1.6 while not in 8.1.7

    I have an application developed on oracle 8.1.6. When I try to port it to oracle 8.1.7.0, it behaves very strangely. Basically the application DB has ' year ' as its column name in some tables. And hence is used in several places in other DB objects.

  • Thunderbolt-firewire connection

    I can not connect my new iMAC 17" computer through Thunderbolt-Firewire cable with my canon camcorder. On my previous iMAC with firewire connection works fine. I am using Pemiere Pro CS6, and now the capture does not work. Any thought?

  • Google Docs error in Safari

    I've started receiving strange error in Safari 8 (Yosemite) when opening a Google Document: https://docs.google.com This error has been reported to Google and we'll into it as soon as possible. Please reload this page to continue Reloading does not h