### TL;DR

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

### 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

```dataprime
source system/engine.queries
| filter queryInfo.semanticLabels.containsJoins == true
| groupby clientInfo.originatingTeamId:number as team aggregate count() as queries
| sortby queries desc
```

### 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

- 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.
