Getting Latest Entry or Just a Unique Entry from Aggregate

Need help with this. For example I have this aggregate with following data items: This is just a mock-up data.

How can I tell Outsystems to just display the latest data without using GroupBy or MAX? The requirement is that there should be no duplicate items on the Table List.

Is there a way. Cant use GroupBy or MAX because I start getting errors.

What's happening is that it's displaying all of the duplicate items on my web page which is a no-no.

Thanks.

Hello Helios,

Can you please use the sorting on created on desc  and set the Max record to 1

Hi Helios,

You can add an filter in aggregate  "Created On desc" and use the aggregate properties Max.Records to limit your output.
Best Regards

Suhas Jamdade wrote:

Hello Helios,

Can you please use the sorting on created on desc.

I do use that to put the latest entry on top. But how do I display it on screen without displaying others with the same Id? 


Igor Khodak wrote:

Hi Helios,

You can add an filter in aggregate  "Created On desc" and use the aggregate properties Max.Records to limit our output.
Best Regards

I think that will display one data only? What if

IdFirst NameLast NameCreated On
13KenShapiro0:03
13KenShapiro0:04
13KenShapiro0:05
14RyuShapiro0:01
14RyuJazz0:01
14RyuJazz0:01
15ZangiefPoro0:04
15ZangiefPoro0:05



Helios wrote:

Igor Khodak wrote:

Hi Helios,

You can add an filter in aggregate  "Created On desc" and use the aggregate properties Max.Records to limit our output.
Best Regards

I think that will display one data only? What if

IdFirst NameLast NameCreated On
13KenShapiro0:03
13KenShapiro0:04
13KenShapiro0:05
14RyuShapiro0:01
14RyuJazz0:01
14RyuJazz0:01
15ZangiefPoro0:04
15ZangiefPoro0:05




Set Max Records to 1

Hi Helios,

That is done with GroupBy and Max. Which errors are you getting?

Regards,

Marcelo

I don't think you can manage this without using a groupby, but if you want to take the long way around.


You can get a list of entries (for instance ID or name) and based on that you perform another aggregate/query with max records 1 and a sort to get the latest entry for that unique entry.

Using a foreach you can loop through all unique entries and get the latest values for them, which you can then put in a struct/list/whatever.

Thought it will be much easier to just use a GroupBy since you will be done with just 1 action.

Hi! 

Are you using aggregates or "advanced SQL " ? 

In SQL you can use the "SELECT DISTINCT" Statement instead of SELECT. 

Regards 

Graça



A distinct would not work in this case.
The created on time in this case is not unique, therefore it will still return multiple rows.
Unless the created on time is removed from the select.

Helios wrote:

Need help with this. For example I have this aggregate with following data items: This is just a mock-up data.

How can I tell Outsystems to just display the latest data without using GroupBy or MAX? The requirement is that there should be no duplicate items on the Table List.

Is there a way. Cant use GroupBy or MAX because I start getting errors.

What's happening is that it's displaying all of the duplicate items on my web page which is a no-no.

Thanks.

Hi Helios,


Can you try in advance query


select id,FirstName,LastName,max(CreatedOn) from tablename
group by id,FirstName,LastName


Thanks,

Balu


Hi guys , thank you so much for the suggestions, too bad I can't mark all your answers as Solutions. Thanks! I'll try them. Im using Aggregates.