6 Replies Latest reply: Oct 16, 2012 6:56 AM by Kabilan Kumarasamy

# How to get the last 10 record of table?

Hi all,

I want to know how to get the last 10 or more record of table?

Regards,

Kabilan K.

• ###### Re: How to get the last 10 record of table?

If you are using v11 you can use dimension limits. If not, try Rank() with Aggr(). Maybe something like,

Hope this helps,

Jason

• ###### Re: How to get the last 10 record of table?

Hi,

I am using V11, So tell me about dimension limit.

Because, my table doesn't have a any numeric column So This expresion is not work (Aggr(If(Rank(Sum(Sales))>=Max(Rank(Sum(Sales)))-10,Customer),Customer)).

Table is like this:

LOAD @1 as FirstDate, //this field have a date, Some dates are very and some dates are same

@2 as Information, //this field have string as 'Information'

@3 as Basedate // This field have Date and some string value

FROM

[\$(FoundFile)]

(txt, utf8, no labels, delimiter is '\t', msq);

Here, how can I get the last 10 record?

Regards,

Kabilan K.

• ###### Re: How to get the last 10 record of table?

Hi,

To get last 10 records of a table in script you can use First attribute and by using Order the table in descending order.

TableName:

*

from abc.qvd

Order by Id desc;

Hope this helps you.

There is no direct way to get last 10 records.

Regards,

Jagan.

• ###### Re: How to get the last 10 record of table?

Hi Kabilan,

You can add the RowNo() function in the table and based on that you can get the max rowno() and in the expression if you write RowID-10 then you will get the last 10 records.

Thanks,

Srini.

• ###### Re: How to get the last 10 record of table?

HI Kabilan,

Try the attach method.

Deepak

• ###### Re: How to get the last 10 record of table?

Hi,

It is fine. But may be it will give a performance issue if I have a lot of txt file

each txt file have 1,00,000 of records.

But we want the 10 records only.

In your sample we have to load the all records and from that we have to take the 10 records.

So, Is possible to solve this another way?