> For the complete documentation index, see [llms.txt](https://docs.chartsql.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chartsql.com/charts/pie.md).

# Pie

<table data-card-size="large" data-view="cards"><thead><tr><th data-card-target data-type="content-ref"></th><th data-hidden></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><a href="/pages/t21pDYIGIJ3qrV5cFxqU#basic-pie-chart">/pages/t21pDYIGIJ3qrV5cFxqU#basic-pie-chart</a></td><td></td><td></td><td></td><td><a href="/files/xIVYZdbcMkmPoaBmXIG8">/files/xIVYZdbcMkmPoaBmXIG8</a></td></tr></tbody></table>

## Basic Pie Chart

```sql
-- @chart: pie
-- @title: Pie - Basic Pie Chart
-- @subtitle: Pie chart of sales won by channel
SELECT
	channel,
	count(*) as TotalSales
FROM sales
WHERE status = 'Won'
GROUP BY channel
ORDER BY TotalSales DESC;
```

<figure><img src="/files/xIVYZdbcMkmPoaBmXIG8" alt=""><figcaption><p>An example pie chart</p></figcaption></figure>

| CHANNEL  | TOTALSALES |
| -------- | ---------- |
| search   | 66.0       |
| coldcall | 37.0       |
| event    | 112.0      |
| referral | 243.0      |
| pr\_ad   | 21.0       |
