> For the complete documentation index, see [llms.txt](https://presight.gitbook.io/presight-v1.0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://presight.gitbook.io/presight-v1.0/model/custom-tables/custom-sql-query.md).

# Custom SQL Query

Your analyst can create a custom query on Presight and use them as a table for modeling data.

You can find **Custom Query Editor** via <mark style="color:blue;">**Data Hub**</mark>, tab <mark style="color:purple;">**Data Source**</mark>

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FmZd4KWGeohCmZ8QlwfBH%2Fimage.png?alt=media&amp;token=a672fbe8-dd10-436a-9300-417dfcc714c1" alt=""><figcaption></figcaption></figure>

Then, you can create a new table by your **Query** and **`Save Query`**

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2F9Q8uPJU1vf1Yt6rsfz1r%2Fimage.png?alt=media&amp;token=d254610f-4a25-430a-b7e0-7bf7f7df6ac4" alt=""><figcaption></figcaption></figure>

Make sure you define the appropriate data type for all columns

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2Ff9IEKSVmCK0sXCNfSKEn%2Fimage.png?alt=media&amp;token=8064bd7a-7647-4567-a280-53234aa1fc7f" alt=""><figcaption><p>Choose data type for each column</p></figcaption></figure>

{% hint style="warning" %}
If you database is in Google BigQuery, the Column Data Type is fixed based on your raw tables. You can check the Column Data Type before saving.
{% endhint %}

And name your **Query**

<figure><img src="https://133649292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIYMCWeQmo9kVg5C6SOyv%2Fuploads%2FSwpCZn0bKMNVNgK5BDkh%2Fimage.png?alt=media&amp;token=0536ef0e-6da5-42b8-bd35-e5d954c81c01" alt=""><figcaption><p>Name your Query</p></figcaption></figure>

After all, you can create Metrics and Dimensions from your newly created table as usual. For more information about how to create a Metric from data tables, check out the link below:

{% content-ref url="/pages/webdopx9Iz6EI8PtAhh3" %}
[Broken mention](broken://pages/webdopx9Iz6EI8PtAhh3)
{% endcontent-ref %}
