Track your spending with a table and a chart

In ten minutes you'll have a spending table and a page that shows where your money goes — updating by itself every time you add a row.

1. Create the table

In your space, create a data table named **Expenses** with these columns:

| Column | Type |

|---|---|

| Name | Name (title) |

| Date | Date |

| Amount | Number, format VND |

| Category | Select — e.g. Food, Transport, Books |

Tip: you can also paste CSV to create the table in one go. The first line becomes the column names.

2. Add a few rows

Type a row per purchase. New categories are added to the Select list as you type them. Dates can be `dd/mm/yyyy` or `yyyy-mm-dd`.

3. Make a page for the summary

Create a text page called **Spending summary** in the same space.

4. Add a chart by category

Add a code block labelled `sql as=chart chart=bar` with this query:

```

SELECT "Category", SUM("Amount") AS "Spent"

FROM "Expenses"

GROUP BY 1

ORDER BY 2 DESC

```

Here's that block running live on the [sample Expenses table](https://openthink.app/n/898391379d30) in this help center:

```sql as=chart chart=bar

SELECT "Category", SUM("Amount") AS "Spent"

FROM "Expenses"

GROUP BY 1

ORDER BY 2 DESC

```

5. Add a monthly total

Use `as=table` to show months as rows:

```sql as=table

SELECT strftime('%m/%Y', "Date") AS "Month", SUM("Amount") AS "Spent"

FROM "Expenses"

GROUP BY 1

ORDER BY MIN("Date")

```

6. Add one big number

`as=number` shows the first row as large numbers — good for a headline:

```sql as=number

SELECT SUM("Amount") AS "Total spent", COUNT(*) AS "Purchases"

FROM "Expenses"

```

Next steps

- Share the summary page with your family — see [Sharing & permissions](https://openthink.app/n/26c72c31ab9c). Remember that anyone who can open the page can read the rows the queries use.

- Build a quick-entry form as an [HTML page](https://openthink.app/n/4727d3d3ab91) that adds rows with `think.executeSql`.

- More query options: [SQL queries & charts](https://openthink.app/n/08d0ba345c4a).