# Is it possible to get Count of distinct field value with groupby in ElasticSearch 1.2.1?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-get-count-of-distinct-field-value-with-groupby-in-elasticsearch-1-2-1/22812>\
**Category:** Elasticsearch\
**Created:** [March 23, 2015, 5:43am UTC](https://discuss.elastic.co/t/is-it-possible-to-get-count-of-distinct-field-value-with-groupby-in-elasticsearch-1-2-1/22812 "2015-03-23T05:43:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [March 23, 2015, 5:43am UTC](https://discuss.elastic.co/t/is-it-possible-to-get-count-of-distinct-field-value-with-groupby-in-elasticsearch-1-2-1/22812/1 "2015-03-23T05:43:05Z")

</div>

Hi all,

I have a set of data as follows:

Date | Unique Visitor Id | Country

13-Mar-2015 | abc | USA  
13-Mar-2015 | xyz | India  
13-Mar-2015 | xyz | India  
14-Mar-2015 | pqr | Japan  
14-Mar-2015 | xyz | USA

I want to fire a query similar to following:  
Select count(distinct unique\_visitor\_id) from table group by Country where  
date='13-Mar-2015'

Please let me know how I can do this in ES 1.2.1?

Regards,  
Rakesh

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2799cb52-b16b-4cc8-9c96-4d330e67e1fc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2799cb52-b16b-4cc8-9c96-4d330e67e1fc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:24am UTC](https://discuss.elastic.co/t/is-it-possible-to-get-count-of-distinct-field-value-with-groupby-in-elasticsearch-1-2-1/22812/2 "2017-07-06T00:24:59Z")

</div>


