# FROM and SHOW

> Choose the object to report on and the numbers to show: metrics, related metrics, math, and functions.

Every query starts with `FROM` and the object to report on, followed by `SHOW` and the numbers you want.

```sql
FROM deals
SHOW count, value, won_value
```

## FROM

```sql
FROM <object>
```

`FROM` takes one object: `deals`, `contacts`, `invoices`, `orders`, `subscriptions` and so on. The [Objects](https://workstation.repzo.com/docs/analytics/repzoql/objects) page lists them all, with what each one holds and whether it can be combined with others.

## SHOW

```sql
SHOW <metric>[, <metric> ...]
```

`SHOW` takes one or more metrics, separated by commas.

| Form | Example | Result |
|---|---|---|
| A metric of the object | `SHOW count, won_value` | The catalog metric |
| A related object's metric | `SHOW deals.won_value` | The metric of the linked records |
| Renamed | `SHOW won_value AS revenue` | The column is called `revenue` |
| Scaled | `SHOW won_value * 12 AS ARR` | The metric times a number |
| Math | `SHOW won_value / won_count AS avg_won` | A calculated metric |
| A function of a field | `SHOW avg(amount), sum(mrr)` | See [Functions](https://workstation.repzo.com/docs/analytics/repzoql/functions) |

### Math

Combine metrics with `+ - * /` and parentheses:

```sql
FROM deals
SHOW won_value * 12 AS ARR,
     won_value / won_count AS avg_won,
     won_count * 100 / count AS win_pct
GROUP BY owner
```

Dividing by zero shows an empty value. In tables, a calculated rate is totaled from its parts, so the totals row stays correct. Money stays money: `won_value / won_count` is shown as currency, while `won_value / value` is a plain number.

### Related metrics

When the object can be [combined](https://workstation.repzo.com/docs/analytics/report-queries#related-records), show the metrics of linked records next to its own:

```sql
FROM contacts
SHOW count, deals.count, deals.won_value, orders.total
GROUP BY source
```

Each object keeps its own permissions and [data visibility](https://workstation.repzo.com/docs/administration/departments).

## Examples

```sql
-- Revenue and order count this month
FROM orders
SHOW total, count
DURING this_month
```

```sql
-- Average won deal per owner
FROM deals
SHOW won_value / won_count AS avg_won
GROUP BY owner
DURING this_year
ON won_at
```

## Related pages

- [Functions](https://workstation.repzo.com/docs/analytics/repzoql/functions)
- [Objects](https://workstation.repzo.com/docs/analytics/repzoql/objects)
- [WHERE](https://workstation.repzo.com/docs/analytics/repzoql/where)
