How to: Display Last n Rows in a table

I am currently running Crystal Reports XI and have been tasked with developing a report that displays only the last 30 rows in a table in ascending order (the records are used for showing data trends over time in a line graph). I have created a Command to extract the records, and by using the TOP 30 statement I can get the first 30 rows in proper order; however, in order to get the last 30 rows I have to sort the records in descending order. This gives me the last 30 rows that I need, but the data is in descending order. Is there another way to get the last 30 rows in a table so that the records come out in ascending order?
The Command I am using looks like this:
SELECT TOP 30 ROWID FROM MYTABLE ORDER BY ROWID DESC
(The ROWID field is alpha numeric)

Hi,
Create a Group based on Rowid in the order-Ascending. This Group should contain all the fields that you require to print along with Rowid.  Therafter insert Summary like sum,count etc for for any field within the group of the type numbervar(numeric). This would activate the Group Sort Expert in the Report Menu. Click on it and select Bottom N (with N as 30) within nature of Sort and suppy the fieldname as Rowid.
Hope this solves.....
Thanks,
Amogh.

Similar Messages

  • How to display multiple selected rows in a table inside a popup?

    Hi,
    I have a table on which multiple selection is enabled. I am able to get hold of multiple selected rows i.e. i am able to iterate over the selected row keys and print their values. Now, my problem is how to display the contents of all the selected rows in a popup? I get the details of only one row when I launch the popup.
    Thanks
    Karan

    Hi,
    Not confident if this works or not but just try it...
    1. create a ViewLink between the same view Object.
    The source and destination wil be the same Vo and the source and destination attribute will be the pk of both Vos.
    2. Update the changes in Appln Module.
    Open the AM and in DataModel tab .
    select the Same VO from which you created table in the DataModel Listbox and select the VL in the "Avaible View Objects" List Box. Add under it(selected vo in datamodel listbox).
    3. Refresh DataControl accordion.
    4. in your jsff page drag and drop the child vo as a table..
    See if it works
    Regards,
    Santosh.

  • How to display All the rows in a Table

    Hi All,
    Our requirement is, we need to display all the records of an VO in a table. We should not have navigation bar with previous and next. Runtime only will come to know how many records the VO has. Is it possible to achieve our requirement using setNumberOfRowsDisplayed() method in OATableBean ?

    Do u want to do it declaratively or programmatically.
    Declaratively You can set no of rows property of table bean. If u want to set it programmatically then u can do it as discussed in the thread..
    Regards,
    Ram

  • How to display number of rows as columns in a select statement? This is on

    How to display number of rows as columns in a select statement? This is on 10g R2.
    Thanks,
    R

    For the current (ie. row 1 of 100)
    row_number over (order by -pick_a_column_set) as rnfor the total number of columns returned in your query
    count(*) over() as total_count

  • Last Inserted Row in a Table

    Hi,
    I want to select only the last inserted row in a table. Can anybody help me how can i get it.
    Eg
    select * from emp;
    empno ename sal
    12 abc 100
    13 xyz 200
    Now i have inserted a row as
    Insert into emp values (14,'Rohit',500);
    So i only want to select the last inserted row i.e.. empno 14 (in this case).
    Thanks
    Bye
    Rohit Taneja

    Thanks to all for replying.
    But the result is not which i desire.
    I have deleted the existing row in the same table as
    SQL> Delete from emp where empno = 13;
    1 row deleted.
    Then i inserted a new row as
    SQL> insert into emp values(10,'SRI',200);
    1 row created.
    Then i committed the work
    SQL> commit;
    Commit complete.
    But still am getting the last row as
    SQL> select * from emp
    where rowid=(select max(rowid)
    from emp);
    EMPNO ENAME SAL
    14 ROHIT 500
    as the solution.
    But here i am supposed to get the row with empno 10.
    I have tried both the queries and still geting the same result.
    Please look aat it again,
    Thanks in advance
    Bye
    Rohit Taneja
    Hi,
    I want to select only the last inserted row in a
    table. Can anybody help me how can i get it.
    Eg
    select * from emp;
    empno ename sal
    12 abc 100
    13 xyz 200
    Now i have inserted a row as
    Insert into emp values (14,'Rohit',500);
    So i only want to select the last inserted row i.e..
    empno 14 (in this case).
    Thanks
    Bye
    Rohit Taneja

  • How to delete a particular row in ALV table

    Hi,
    How to delete a particular row in ALV table based on some condition(by checking value for one of the columns in a row)
    Thanks
    Bala Duvvuri

    Hello Bala,
    Can you please be a bit more clear as to how you intend to delete the rows from your ALV? By the way deleting rows from an ALV is no different from deleting rows from a normal table. Suppose you have enabled selection property in ALV & then select multiple rows and click up on a button to delete the rows then below would be the coding: (Also keep in mind that you would have to maintain the Selection property of the context node that you are binding to your ALV to 0..n)
    data : lr_table_settings  TYPE REF TO if_salv_wd_table_settings,
                 lr_config          TYPE REF TO cl_salv_wd_config_table.
      lr_table_settings  ?= lr_config.
    ** Setting the ALV selection to multiple selection with no lead selection
      lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
    Next delete the selected rows in the action triggered by the button:
    METHOD onactiondelete_rows .
      DATA:  wd_node TYPE REF TO if_wd_context_node,
             lt_node1 TYPE ig_componentcontroller=>elements_node,
             wa_temp  TYPE REF TO if_wd_context_element,
             lt_temp  TYPE wdr_context_element_set,
             row_number TYPE i VALUE 0.
      wd_node = wd_context->get_child_node( name = 'NODE' ).
      CALL METHOD wd_node->get_selected_elements
        RECEIVING
          set = lt_temp.
      LOOP AT lt_temp INTO wa_temp.
        wd_node->remove_element( EXPORTING element = wa_temp ).
      ENDLOOP.
      CALL METHOD wd_node->get_static_attributes_table
        EXPORTING
          from  = 1
          to    = 2147483647
        IMPORTING
          table = lt_node1.
      wd_node->bind_table( new_items = lt_node1 ).
    ENDMETHOD.
    If in case this isn't your requirement please do let me know so that I can try come up with another analysis.
    Regards,
    Uday

  • How to find newly updated rows in a table

    Hi..
    How to know newly updated rows in a table.
    Thanks in advance
    pal

    Or other good thing would be to add LAST_UPDATED column to your table, that can reflect the time the row gets updated.
    G

  • How to get count of rows for a table?

    Hi,
    How to get count of rows for a table and secondly, how can i have access to a particular cell in a table?
    Regards,
    Devashish

    Hi Devashish,
    WdContext.node<Your_node_name>().size() will give you the no: of rows.
    This should be the node that is bound to the table's datasource property.
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value); will select the row at that particular index.
    You can access an attribute of a particular row as
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value).get<attribute_name>();
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • How to list all the rows from the table VBAK

    Friends ,
    How to list all the rows from the table VBAK.select query and the output list is appreciated.

    Hi,
    IF you want to select all the rows for VBAK-
    Write-
    Data:itab type table of VBAK,
           wa like line of itab.
    SELECT * FROM VBAK into table itab.
    Itab is the internal table with type VBAK.
    Loop at itab into wa.
    Write: wa-field1,
    endloop.

  • How to Display IMAGE BLOB stored in a table in a html region APEX

    Need to know how to display an image stored in a table in a HTML APEX Region.
    Please

    Hi
    Please explain what you mean by it doesn't work?
    Are there errors messages, at what point, how far did you get and exactly what did you do????
    Please provide more information.
    Thanks
    Ben

  • How to find last inserted record in the table.

    Version: Oracle 10g
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".
    As i come to know that Rowid is not result perfect results. Please provide your inputs.

    user13416294 wrote:
    Version: Oracle 10gThat is not a version. That is a product name. A version is 10.1.0.2 or 10.2.0.4, etc.
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".Not possible as your data model does not cater for it. That simple.
    If there is a need to determine some order or associate some time to an entity, then that should be part of the data model - and a relationship, or one or more attributes are needed to represent that information. Thus your data model in this case is unable to meet your requirements.
    If the requirements are valid, fix the data model. In other words - your question has nothing to do with Oracle and nothing to do with rowid, rowscn or other pseudo columns in Oracle. It is a pure data modeling issue. Nothing more.

  • Display all the rows in the table with Varray

    I created two Varrays
    CREATE TYPE phone_varray AS VARRAY(3) OF NUMBER(10);
    CREATE TYPE email_varray AS VARRAY(3) OF varchar2(30);
    CREATE TABLE ee
    (id number(2),
    phone phone_varray);
    now i inserted some rows into ee table and displayed it as:
    SELECT e1.id,e2.COLUMN_VALUE"PHONE NO" FROM ee e1,TABLE(e1.phone) e2;
    ID PHONE NO
    1 1111111111
    1 2222222222
    1 3333333333
    1 1111111111
    1 2222222222
    1 4444444444
    4 1111
    4 2222
    4 33334
    5 1111
    5 2222
    5 33334
    Then i altered the table with email_varray
    desc ee;
    Name Null? Type
    ID NUMBER(2)
    PHONE PHONE_VARRAY
    EMAIL EMAIL_VARRAY
    I updated some rows:
    update ee e1 set email=email_varray('aasda') where id=4;
    and when i try to display the table data by:
    SELECT id,e2.*,e3.* from ee e1,TABLE(e1.phone) e2,TABLE(e1.email) e3;
    it only displays the rows that contain all the details like
    ID COLUMN_VALUE COLUMN_VALUE
    4 1111 aasda
    4 2222 aasda
    4 33334 aasda
    and not all the rows that are in the table which have id and phone and email as NULL
    need help to display all the rows in the table.

    will this work for you ?
    SELECT e1.id,e2.COLUMN_VALUE as PHONE_NO, null as email FROM ee e1,TABLE(e1.phone) e2
    union
    SELECT e1.id,null,e3.column_value as email from ee e1, TABLE(e1.email) e3;

  • How to Display last Login Details in MasterPage

    Hi,
    we have one requirement,i.e.When any user logged into the site, we need to display last login time for that user.
    We are getting last logged user date and time based on user id and updating that value into the list column(like this 4/3/2015 8:38:32 PM).But we need to add this into default master page.
    How to do this one ...can anyone suggest me ....
    Thanks...

    Hi,
    I hope you are trying to show your login date from SharePoint List.
    My suggestion is 
    1. by using ECMA Script ,retrieve values from that list and show the same in Master Page.
    2. If you are not comfortable with ECMA, develop Visual Webpart and add the Visual Webpart in master page by using SharePoint Designer.
    Please let me know ,if you need further guidance.
    Don't forget to mark it as an Answer if it resolves your issue and Vote Me as helpful if it useful.
    Mahesh

  • How to display first 5 rows with a specific filter

    Hi All,
    Please do have a look at the below mentioned query.
    select * from emp where empnm like 'B%';Now suppose it will display 10 rows. But I want to display first 5 rows out of them.
    How can I do that? I tried this with rownum and rowid. It worked because the records are in order,
    but if those records are in arbitrary order, now what? What should be done here?
    Regards,
    BS2012.

    BS2012 wrote:
    Hi All,
    Please do have a look at the below mentioned query.
    select * from emp where empnm like 'B%';Now suppose it will display 10 rows. But I want to display first 5 rows out of them.
    How can I do that? I tried this with rownum and rowid. It worked because the records are in order,
    but if those records are in arbitrary order, now what? What should be done here?
    Regards,
    BS2012.This will display the first 5 records no matter of the order
    select * from emp where empnm like 'B%'
    and rownum <=5;This will display the first 5 records after ordering them
    select * from (select * from emp where empnm like 'B%' order by empnm) where rownum <=5 ;Regards.
    Al
    Edited by: Alberto Faenza on Oct 11, 2012 5:49 PM
    Edited by: Alberto Faenza on Oct 11, 2012 5:50 PM

  • Display last two rows for every group

    Hi,
    I want to display only last 2 rows for every group.
    My table look like
    ACN DATE COST APPL
    A6ERA 14-JUN 150 B777
    A6ERA 14-JUN 180 B787
    A6ERA 15-JUN 120 B677
    A6ERA 14-JUN 155 B777
    A6ERB 13-JUN 166 A777
    A6ERB 14-JUN 157 B777
    A6ERB 11-JUN 159 B787
    A6ERC 14-JUN 099 B777
    A6ERC 11-JUN 102 B788
    In the above table, I want to display only the last two rows group by ACN
    Like the below table
    ACN DATE COST APPL
    A6ERA 15-JUN 120 B677
    A6ERA 14-JUN 155 B777
    A6ERB 14-JUN 157 B777
    A6ERB 11-JUN 159 B787
    A6ERC 14-JUN 099 B777
    A6ERC 11-JUN 102 B788
    Please reply

    Nihar
    To get the first two rows from each group, you could do this:
    Use the ROW_NUMBER() analytic function (see http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions137.htm#i86310)
    Now, your question isn't clear what you mean by "last" two rows. Last in what order? Whatever it is, you can use the ORDER BY part of the ROW_NUMBER() function to specify the ordering, and reverse it using DESC - for example:
    select acn, adate, cost, appl from (
        select acn, adate, cost, appl,
                  row_number() over (partition by acn order by adate desc) as rn
        from  acntab
    where rn <= 2
    order by acn, rnHTH
    Regards Nigel

Maybe you are looking for

  • How do I set up a RAID array with an external hard drive?

    Im trying to backup my hard drive onto a 250 GB external hard drive (connected by Firewire) via a RAID 1 configuration. What is the best way to do this? MacBook   Mac OS X (10.4.6)   Intel-based, Windows XP Pro is installed via Boot Camp

  • Money has been taken from my bank account for items I havnt purchased, Who do I contact about this

    Money has been taken from my bank account for items I hav'nt purchased, My bank says to contact I tunes but I cannot find out who to contact, so trying this to see if anyone else has had the same problem

  • RBAC question

    Hi, I came across a tutorial which teaches how to grant reboot permission to a user. At one point, it says to add the following line to ' /etc/security/exec_attr' file REBOOT:suser:cmd:::/usr/sbin/reboot:euid=0I will need to grant access to other com

  • How to make Open Source work on Solaris 10, x86 ?

    I'm trying to make this Open Source code for MDBTools work on my Solaris 10, x86. What this tool does is to read in a Microsoft Access MDB file, and outputs the contents of that database file, into an ASCII text file. I unzipped these files already,

  • Checking the bank for buyings...

    I have 3 computers on the same bankaccount. But each computer has its own user/account so I dont see on a email what they have bought. Now when I get my bankaccount I wanna know what has been bought so I can check the bankaccount. where on itunes can