# Query according to type classification, and statistics

**URL:** <https://discuss.dgraph.io/t/query-according-to-type-classification-and-statistics/14964>\
**Category:** GraphQL\
**Created:** [July 15, 2021, 1:51am UTC](https://discuss.dgraph.io/t/query-according-to-type-classification-and-statistics/14964 "2021-07-15T01:51:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soultrans](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/soultrans/32/4919_2.png) [@Soultrans](https://discuss.dgraph.io/u/Soultrans)\
**Post date:** [July 15, 2021, 1:51am UTC](https://discuss.dgraph.io/t/query-according-to-type-classification-and-statistics/14964/1 "2021-07-15T01:51:46Z")

</div>

```auto
$ dgraph version
V20.03

```

* * *

### What you wanted to do

I want to query according to the classification of \<dgraph.type\>，and count the number under each category

### What you actually did

Please excuse my poor GraphQL, I can’t get any information, may I ask how to write ？

```auto
{
   var(func:has(dgraph.type)){
    <dgraph.type> @groupby(<dgraph.type>){
      a as count(uid)
    }
  }
    
  Classification(func:uid(a)){
    <dgraph.type>
    tota:val(a)
  }
 }

```

The error message is as follows：

```auto
Error Name: t
Message: : context deadline exceeded
Raw Error:

{
  "name": "t",
  "url": "http://0.0.0.000:8080/query?timeout=20s&debug=true",
  "errors": [
    {
      "message": ": context deadline exceeded",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![Soultrans](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/soultrans/32/4919_2.png) [@Soultrans](https://discuss.dgraph.io/u/Soultrans)\
**Post date:** [July 20, 2021, 2:28am UTC](https://discuss.dgraph.io/t/query-according-to-type-classification-and-statistics/14964/2 "2021-07-20T02:28:27Z")

</div>

Who can help me? 🤣

---

<div class="post-metadata">

**Author:** ![pshaddel](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pshaddel/32/11584_2.png) [@pshaddel](https://discuss.dgraph.io/u/pshaddel)\
**Post date:** [July 22, 2021, 10:17pm UTC](https://discuss.dgraph.io/t/query-according-to-type-classification-and-statistics/14964/3 "2021-07-22T22:17:40Z")

</div>

Hi @Soultrans  
First thing you need to know is that there is a different between `dql` and `GraphQL`. The query that you wrote is a dql(Dgraph Query Language). You can execute dql queries using Ratel. Take a look at this tuturial: [Dgraph tutorials series - 1: Getting started - Dgraph Blog](https://dgraph.io/blog/post/tutorial-1-getting-started/)  
The query you need to execute to get this information is something like this:

```auto
{
  getTypes(func: has(dgraph.type)) @groupby(dgraph.type) {
    count(uid)
  }
}

```

Also the error you got is because your query execution took more than 20 second which is the default query timeout in Ratel and you can see `20s` in the url you pasted there.
