# Sort and Stats Aggregation

**URL:** <https://discuss.elastic.co/t/sort-and-stats-aggregation/254426>\
**Category:** Elasticsearch\
**Created:** [November 5, 2020, 2:37pm UTC](https://discuss.elastic.co/t/sort-and-stats-aggregation/254426 "2020-11-05T14:37:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhinav\_elk](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@abhinav\_elk](https://discuss.elastic.co/u/abhinav_elk)\
**Post date:** [November 5, 2020, 2:37pm UTC](https://discuss.elastic.co/t/sort-and-stats-aggregation/254426/1 "2020-11-05T14:37:01Z")

</div>

I have a mapping of type

```auto
    {
       "properties":{
          "Costs":{
             "type":"nested",
             "properties":{
                "price":{
                   "type":"integer"
                }
             }
          }
       }
    }

```

I want to find minimum of price in the Costs array of each document and then find min,max price of those minimums.  
So basically kind of sort of minimums and then stats aggregation over those minimums.  
Can this be done, let me know if any clarity is required

---

<div class="post-metadata">

**Author:** ![abhinav\_elk](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@abhinav\_elk](https://discuss.elastic.co/u/abhinav_elk)\
**Post date:** [November 11, 2020, 11:28am UTC](https://discuss.elastic.co/t/sort-and-stats-aggregation/254426/2 "2020-11-11T11:28:11Z")

</div>

Can someone please help here.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 9, 2020, 11:28am UTC](https://discuss.elastic.co/t/sort-and-stats-aggregation/254426/3 "2020-12-09T11:28:13Z")

</div>

Closed on December 9, 2020, 11:28am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
