# Getting LAST record in aggr in ES|QL

**URL:** <https://discuss.elastic.co/t/getting-last-record-in-aggr-in-es-ql/372903>\
**Category:** Elasticsearch\
**Tags:** esql\
**Created:** [January 7, 2025, 5:35pm UTC](https://discuss.elastic.co/t/getting-last-record-in-aggr-in-es-ql/372903 "2025-01-07T17:35:55Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [March 2, 2026, 6:12pm UTC](https://discuss.elastic.co/t/getting-last-record-in-aggr-in-es-ql/372903/11 "2026-03-02T18:12:02Z")

</div>

Look at the [TOP](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions/top) function, as enhanced in 9.3.0+

Sadly the outputField is a bit limited, allowing a keyword field as outputField would be a massive enhancement in many use cases IMHO, but it might be useful in your case?

I asked about this [here](https://discuss.elastic.co/t/further-enhance-top-es-ql-function-please/384898) but sadly got no answer.

---

_[View the full topic](https://discuss.elastic.co/t/getting-last-record-in-aggr-in-es-ql/372903)._
