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

# SQL and AI for beginners

> Understand SQL in plain language and use Prism's AI tools to turn a business question into a report.

You do not need to know SQL to use Prism. Start with a template, describe what you need to the built-in SQL assistant, or ask the Yorlet Assistant to create and run a Prism query for you.

## What SQL means

SQL is a way of asking a database a precise question. A database is an organised collection of information. In Prism:

* A **table** is a type of Yorlet record, such as Customers, Invoices, Units, or Tenancies.
* A **row** is one record, such as one Invoice or one Unit.
* A **column** is a detail on that record, such as its status, amount, or date.
* A **query** is the question written in SQL.
* A **result** is the set of rows Prism returns.

For example, this query asks for every available Unit:

```sql theme={"theme":"dracula"}
select
  name,
  bedrooms,
  default_price / 100.0 as monthly_rent
from units
where status = 'available'
order by monthly_rent desc
```

You do not need to write this yourself. You could ask the assistant: **Show available units with the unit name, number of bedrooms, and monthly rent in pounds. Put the highest rent first.**

<Note>
  Prism only reads from a snapshot of your Yorlet data. A query cannot edit, delete, or send anything, so it is safe to
  experiment.
</Note>

## Three ways to begin

Choose the route that feels most comfortable:

1. **Use a template** when a report is close to something common, such as rent roll, arrears ageing, or vacant Units.
2. **Ask the SQL assistant in Prism** when you want to build or change a reusable query in the editor.
3. **Ask the Yorlet Assistant** when you want to ask a question in plain English and see an answer without working in the editor.

If you are new to Prism, start with a [template](/prism/templates), then ask the SQL assistant to adjust it. This gives the assistant a useful starting point and lets you see each change.

## Ask the SQL assistant in Prism

The field above the editor says **Ask assistant to edit this query**. It changes the SQL in the editor but does not run it. You decide when to click **Run**.

To create a query with the SQL assistant, follow these steps:

1. Open [Prism](https://dashboard.yorlet.com/prism).
2. Click **New**, or choose a [template](/prism/templates).
3. In **Ask assistant to edit this query**, describe the report you need.
4. Press Enter and wait for the SQL in the editor to change.
5. Read the short explanation and check that the query matches your request.
6. Click **Run**.
7. Check the result, then ask for another change if needed.
8. Give the query a clear name and click **Save** if you want to use it again.

Useful follow-up requests include:

* Show amounts in pounds instead of pence.
* Only include active Tenancies.
* Limit this to the last full calendar month.
* Group this by Building and add a total.
* Add the Customer's name.
* Put the largest balance first.
* Remove email addresses from the result.
* Explain this query in plain English.

If the query fails, click **Fix error** or **Fix with assistant**. The error is sent to the SQL assistant so it can correct the query.

## Write a useful prompt

A good prompt says what you want to see, which records to include, the time period, and how to organise the answer. You can write naturally; you do not need to use database terms.

Try this pattern:

> Show **\[information]** for **\[which records]** during **\[time period]**. Group or sort it by **\[category]**. Include **\[useful columns]**.

For example:

* Show active Tenancies ending in the next 90 days. Include the Building, Unit, end date, and monthly rent in pounds. Put the soonest end date first.
* Show open Invoices that are overdue. Group the outstanding balance into 0–30, 31–60, 61–90, and over 90 days.
* Compare successful Payment value by month for the last 12 complete months.
* Show available Units by Building, with bedroom count and default rent. Add one total row per Building.
* Show open maintenance issues by priority and Building. Exclude resolved issues.

<Tip>
  Add one change at a time. It is easier to check “now group by Building” than to diagnose a long prompt with many
  requirements.
</Tip>

## Use Prism with the Yorlet Assistant

The Yorlet Assistant can draft Prism SQL and run the query in the chat. This is useful for one-off questions when you care about the answer more than the SQL.

To ask the Yorlet Assistant, follow these steps:

1. Open [Home](https://dashboard.yorlet.com/dashboard), or open the Assistant side panel with **⌘ /** (Control / on Windows).
2. Ask a question and mention Prism, for example: **Use Prism to show monthly Payment value for the last 12 months.**
3. The assistant shows the proposed **Prism SQL** and a short explanation.
4. It runs the query and shows a **Prism query** result in the chat.
5. Ask a follow-up, such as **Now split that by Building** or **Show the values in pounds**.

The Yorlet Assistant is best for exploring a question. Use the Prism editor when you want to save the query, schedule it, chart it, or download its result.

<Note>
  Using Prism through the Yorlet Assistant requires access to both products. Your message uses your Yorlet AI message
  allowance, and drafting the SQL uses your Prism AI SQL allowance.
</Note>

## Check an AI-written query

AI is a helpful starting point, but you should still check that the answer makes sense before sharing or acting on it:

1. In the Prism editor, check **Data as of** so you know how recent the snapshot is.
2. Check the filters. For example, confirm whether the query includes only `active` Tenancies or all statuses.
3. Check the time period, especially phrases such as “last month” and “last 30 days”.
4. Check the unit of money. Prism stores amounts in pence, so reports in pounds should divide by 100.
5. Check the row count and whether the result says **truncated**.
6. Compare a small sample with the relevant records in Yorlet.
7. Remove personal information you do not need before downloading or sharing a CSV.

If something looks wrong, tell the assistant what you expected and what looks incorrect. For example: **This includes completed Tenancies. Change it to active Tenancies only and explain the filter.**

## A few SQL words you may see

You can use Prism without learning these, but recognising them makes an AI-written query easier to review:

* `select` — chooses the columns or calculations to show.
* `from` — chooses the main table.
* `where` — filters which records are included.
* `order by` — sorts the result.
* `group by` — combines records into totals, such as one total per Building.
* `count` — counts records.
* `sum` — adds values together.
* `join` — connects related tables, such as Units to Buildings.
* `as` — gives a result column a clearer name.

Open the [Schema](/prism/schema) when you want to see which records and details Prism makes available. You can also ask the SQL assistant to choose the right table and explain why.
