# FIRST/FIRST\_VALUE function returning empty value

**URL:** <https://discuss.elastic.co/t/first-first-value-function-returning-empty-value/263963>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [February 11, 2021, 8:06am UTC](https://discuss.elastic.co/t/first-first-value-function-returning-empty-value/263963 "2021-02-11T08:06:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitarorait82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohitarorait82/32/82981_2.png) [@rohitarorait82](https://discuss.elastic.co/u/rohitarorait82)\
**Post date:** [February 11, 2021, 8:06am UTC](https://discuss.elastic.co/t/first-first-value-function-returning-empty-value/263963/1 "2021-02-11T08:06:02Z")

</div>

Hi All,

I have to select records from an index, and have to select the latest values for a Mobile number. There can be more than one record for each mobile number.

I am using **FIrst** function for the same and it is returning me the latest values. However I have to ignore if the latest value is blank and select the next value

Is there a way/function to select the latest non blank value from an index using sql Api

---

<div class="post-metadata">

**Author:** ![matriv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matriv/32/43656_2.png) [@matriv](https://discuss.elastic.co/u/matriv)\
**Post date:** [February 11, 2021, 1:23pm UTC](https://discuss.elastic.co/t/first-first-value-function-returning-empty-value/263963/2 "2021-02-11T13:23:26Z")

</div>

You could use the `IS NOT NULL` in the WHERE clause.  
Can you post the query you're trying to run?

---

<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:** [March 11, 2021, 1:24pm UTC](https://discuss.elastic.co/t/first-first-value-function-returning-empty-value/263963/3 "2021-03-11T13:24:07Z")

</div>

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