# Count queries using joins by team

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Fcookbook%2Fcount_queries_by_team.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Fcookbook%2Fcount_queries_by_team.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

### TL;DR[​](#tldr "Direct link to TL;DR")

Group engine query logs by team and count how many queries include a `JOIN`.

### Problem / Use case[​](#problem--use-case "Direct link to Problem / Use case")

You want to find which teams are running the most DataPrime queries that include `JOIN` operations. This helps identify heavy or complex usage patterns for optimization or review.

### Query[​](#query "Direct link to Query")

```
source system/engine.queries

| filter queryInfo.semanticLabels.containsJoins == true

| groupby clientInfo.originatingTeamId:number as team aggregate count() as queries

| sortby queries desc
```

### Expected output[​](#expected-output "Direct link to Expected output")

| team   | queries |
| ------ | ------- |
| 007    | 42      |
| 73     | 108     |
| 314159 | 271828  |
| ...    | ...     |

Each document shows a team ID and the total number of queries containing join operations, sorted from highest to lowest.

### Variations[​](#variations "Direct link to Variations")

* Replace `clientInfo.originatingTeamId` with `clientInfo.originatingUserId` to view usage per individual user.
* Add a time filter such as `| filter $m.timestamp > now() - 1d` to view recent join activity.
