# Returning a simple projection of fields

**URL:** <https://discuss.elastic.co/t/returning-a-simple-projection-of-fields/27239>\
**Category:** Elasticsearch\
**Created:** [August 12, 2015, 8:05am UTC](https://discuss.elastic.co/t/returning-a-simple-projection-of-fields/27239 "2015-08-12T08:05:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dceder906](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dceder906](https://discuss.elastic.co/u/dceder906)\
**Post date:** [August 12, 2015, 8:05am UTC](https://discuss.elastic.co/t/returning-a-simple-projection-of-fields/27239/1 "2015-08-12T08:05:19Z")

</div>

I am new to ElasticSearch.

How do I simply get the equivalent to this SQL statement as a CSV formatted file:  
SELECT field1, field2, COUNT(field3)  
FROM MyTable  
GROUP BY field1, field2

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 12, 2015, 8:24am UTC](https://discuss.elastic.co/t/returning-a-simple-projection-of-fields/27239/2 "2015-08-12T08:24:34Z")

</div>

You should have a look at aggregations and do something like a termsAgg on field1 add an inner termsAgg on field2.

That should give you something close to your needs.

---

<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 5, 2017, 11:56pm UTC](https://discuss.elastic.co/t/returning-a-simple-projection-of-fields/27239/3 "2017-07-05T23:56:16Z")

</div>

Closed on July 5, 2017, 11:56pm UTC


