# Build a query to select max value for a particular atribute

**URL:** <https://forum.bubble.io/t/build-a-query-to-select-max-value-for-a-particular-atribute/19946>\
**Category:** Database\
**Created:** [November 2, 2017, 2:54pm UTC](https://forum.bubble.io/t/build-a-query-to-select-max-value-for-a-particular-atribute/19946 "2017-11-02T14:54:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjuchand](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@sanjuchand](https://forum.bubble.io/u/sanjuchand)\
**Post date:** [November 2, 2017, 2:54pm UTC](https://forum.bubble.io/t/build-a-query-to-select-max-value-for-a-particular-atribute/19946/1 "2017-11-02T14:54:20Z")

</div>

I have a data type called check in where I store the member id and membership expiry date. Every time a member renews the membership, the expiry date gets updated to today or sometime in future depending on daily/monthly membership.

How can I show the membership expiry date for a member in a text field? the sql query will be

select max(membership expiry date) from check-in where member-id=xyz.

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [November 2, 2017, 7:40pm UTC](https://forum.bubble.io/t/build-a-query-to-select-max-value-for-a-particular-atribute/19946/2 "2017-11-02T19:40:29Z")

</div>

Do a search, sort on Expiry Date then select the highest using : first item
