cancel
Showing results for 
Search instead for 
Did you mean: 

how to display last 10 records in crystal reports

Former Member
0 Kudos

Hi All,

I know it is a easy one.Please tell

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use Group Sort Expert to select Top/Bottom N records. Or if you are trying to sort data by a field and extracting data from database then you can simply use the following query.

SELECT TOP N *

FROM MyTable

ORDER BY Id DESC

Regards

Anil

Former Member
0 Kudos

Hi Mehar,

I don't have any groups.

I have some records and i need to show top 10 using report level logic.

Please suggest

abhilash_kumar
Active Contributor
0 Kudos

Hi Diva,

Go to the Record Sort Expert and sort by a Database field in Descending Order.

Create a formula:

Whilereadingrecords;

Numbervar x:= x+1;

Go to Record Selection formula and use this :

{@formulaname} <= 10

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

I don't want to apply sort on any field.

Simply i have some records.I need to display last 10 records.

I tried your solution but not succeeded.

PFA

Former Member
0 Kudos

Hi divya ,

use this query

select *  from tablename order by  fieldname (like docnum)desc

and put suppress condition in details section recordnumber>10

-Rajesh N

abhilash_kumar
Active Contributor
0 Kudos

Please be more specific.

Do you want to list last 10 records in every group?

Are you sure there is no sorting applied on any field at the moment?

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

There is no sorting for any field.I applied sort for group only.

Anyway tried with sample report.But unable to get the result.

Please check the below report.

Here there is no group and i followed the same process you told.But it is showing 1st 10 records.

abhilash_kumar
Active Contributor
0 Kudos

In your original report I see a group whereas in your sample there is no group. The solutions for a group vs no group are different. For a Group Report, assuming no field has been used to sort (other than the group of course) here's what you need to do:

1) Right-click the details section > Click the formula button beside suppress and use this code:

numbervar x := x + 1;

x <= Count({database_field}, {Group_field}) - 10

2) Create a reset formula formula and place it on the GH2:

whileprintingrecords;

numbervar x := 0;

-Abhilash

Former Member
0 Kudos

Just another way is to handle this at query-level using the command SQL object ( Add Command feature).

for e.g in Oracle:

select * from (select * from table_name1 group by column_name desc) table_name2

where rownum < = 10

order by rownum desc

-Prathamesh

Former Member
0 Kudos

Hi Abhilash,

This is working for group.

In case i didn't have any group .say i have 4 fields having 100 records and i need to display last 10 records.

How can i do this.

Please suggest

abhilash_kumar
Active Contributor
0 Kudos

1) Use this code as the Suppress formula:

numbervar x := x + 1;

x <= Count({database_field}) - 10

2) Remove the Reset formula.

You can even use this as the suppress formula:

RecordNumber <= Count({database_field}) - 10

-Abhilash

Former Member
0 Kudos

Estimados, buenas

Consulta Una, si Tengo sin detalle porción EJEMPLO de las Cantidades vendidas de los articulos pero quiero agregar un cuadro resumen (puede ser tabla de referencias cruzadas) como puedo solo filtrar los 10 articulos mas vendidos en crystal reports?

favor alguna sugerencia??

Atte.

carlos

Answers (0)