> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yorlet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Write a query

> Run SQL in Prism, ask the assistant to edit it, and inspect the result as a table, chart, or CSV.

The Prism editor is where you write SQL against your snapshot, run it, and read the result. Open [Prism](https://dashboard.yorlet.com/prism) after you have a plan.

The status line shows **Data as of** when the snapshot was last built. **Standard** refreshes overnight; **Premium** refreshes every hour.

## Run a query

To run a query, follow these steps:

1. Open [Prism](https://dashboard.yorlet.com/prism).
2. Type SQL in the editor, or pick a [template](/prism/templates).
3. Click **Run**, or press **⌘ ↵** (Control Enter on Windows).

The editor shows at most 10,000 rows. Use the menu next to **Run** for **Run with 1,000 row limit** when you want a smaller cap.

The result area shows how many rows came back, whether the result was truncated, and how long the query took. Switch between **Table** and **Chart**. Chart needs at least one text column and one number column.

Click **CSV** to download the rows shown in the editor. On **Premium**, **Full result** appears when the result is truncated.

Click **Format** to tidy the SQL. Give the query a name by clicking the title or the pencil next to it. See [Save and schedule](/prism/save-and-schedule) to keep the query.

<Tip>
  Amounts are in pence. Divide by 100 for pounds. Timestamps are in UTC.
</Tip>

## Ask the assistant to edit the query

The field above the editor is **Ask assistant to edit this query**. Describe the report you want in plain language. The assistant rewrites the SQL in the editor. You still click **Run** to execute it.

On **Standard**, you have 25 AI SQL generations each calendar month. **Premium** is unlimited. Asking the assistant, **Fix error**, and **Fix with assistant** all count.

If a query fails, the result area shows the error. Click **Fix error** or **Fix with assistant** to send the error back to the assistant.

## Query across accounts

In organisation view, open [Prism](https://dashboard.yorlet.com/org/prism). The **Query scope** control in the header chooses which accounts the SQL runs against:

* **All accounts** — every account in the organisation that has Prism enabled.
* **Groups** — the Prism-enabled accounts in that group.
* **Accounts** — tick the accounts you want.

Accounts without Prism are labelled **Prism not enabled** and cannot be selected. Each account still needs its own [plan](/prism/plans). Queries use this account’s Prism plan for refresh, row limits, and AI SQL assist.

When the result includes more than one account, filter further in SQL with `account_id`. Changing scope clears the last result so you do not mix rows from different selections.

## What you can write

Use a single `SELECT` (or `WITH` … `SELECT`). Prism will not run statements that change data or attach other databases.

Use [tenancies](/prism/schema#tenancies-and-applications) for rent roll and occupancy. Use [applications](/prism/schema#tenancies-and-applications) for the leasing pipeline.
