> 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

Pie charts show the relative contribution of values in relationship to the whole

<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="/charts/pie.md#basic-pie-chart">Pie</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FGW1xhdFUKqVBGjM6fegO%2Fpie_example.jpg?alt=media&amp;token=45b90d4a-20d4-4073-bc99-96633a45b06c">pie_example.jpg</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="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FGW1xhdFUKqVBGjM6fegO%2Fpie_example.jpg?alt=media&amp;token=45b90d4a-20d4-4073-bc99-96633a45b06c" 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       |
