# Retain long data type value in SQL output

**URL:** <https://discuss.elastic.co/t/retain-long-data-type-value-in-sql-output/246997>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [August 31, 2020, 6:11pm UTC](https://discuss.elastic.co/t/retain-long-data-type-value-in-sql-output/246997 "2020-08-31T18:11:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![askids](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/askids/32/22252_2.png) [@askids](https://discuss.elastic.co/u/askids)\
**Post date:** [August 31, 2020, 6:11pm UTC](https://discuss.elastic.co/t/retain-long-data-type-value-in-sql-output/246997/1 "2020-08-31T18:11:33Z")

</div>

hi,

I am trying to get min value of an attribute using SQL api. My query looks like this  
`SELECT MIN(attr1) as min_val from index_name`

However, in the output, the value is getting converted to scientific value and is loosing precision. Its showing value as 1.0E18.

Is there any way to retain the value as is? I tried using both variants of CONVERT/CAST on top of MIN. I am getting input mismatch, input '(' expecting ')'.

I am on ES7.2.0 default installation using Windows MSI.

Thanks!

---

<div class="post-metadata">

**Author:** ![bogdan.pintea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bogdan.pintea/32/45740_2.png) [@bogdan.pintea](https://discuss.elastic.co/u/bogdan.pintea)\
**Post date:** [September 10, 2020, 11:01am UTC](https://discuss.elastic.co/t/retain-long-data-type-value-in-sql-output/246997/2 "2020-09-10T11:01:28Z")

</div>

> [@askids](#):
>
> However, in the output, the value is getting converted to scientific value and is loosing precision.

That should not happen and on a quick test with a new 7.2.0 deployment is does not indeed happen.

> [@askids](#):
>
> Its showing value as 1.0E18.

Are you seeing this `1.0E18` in the REST answer, or is this answer being interpreted by another application that renders it to you?

> [@askids](#):
>
> I am trying to get min value of an attribute using SQL api.

If you're using the REST API directly, could you share the URL starting from the path (`/_sql`) and the REST request object being sent to the SQL REST API?  
The `attr1` source of the document that contains the minimum value would also be useful.

---

<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:** [October 8, 2020, 11:01am UTC](https://discuss.elastic.co/t/retain-long-data-type-value-in-sql-output/246997/3 "2020-10-08T11:01:29Z")

</div>

Closed on October 8, 2020, 11:01am UTC

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