# Query Editor

### What is it?

The Query Editor, in comparison to the Explorer, is a more technical and flexible way for you to collect data by writing your own SQL queries.

Write any [**ClickHouse**](https://clickhouse.com/docs/en/) compatible SQL and execute it to get the data you're looking for. All SQL statements will be executed against your ClickHouse database.

## How to use it

When you enter the Query Editor the text editor will always be a blank canvas for you to start writing your own SQL.

Let's run through the different options you have.

#### **NEW**

Clicking on 'New' will simply clear the editor from any SQL.

<figure><img src="https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2Fs0BjqWtPj8WZBuHf4IvQ%2FNew%20Query.gif?alt=media&#x26;token=5b540a80-2989-4b9f-a285-a28ece64beaf" alt=""><figcaption></figcaption></figure>

#### **EXECUTE**

Write your SQL in the editor, and by clicking on 'Execute' you will allow the query to run.&#x20;

![Successful query](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2F35Iox20IEK0Hu26DaN4L%2FExecute%20Query.gif?alt=media\&token=8a4fcea5-efbb-4043-a9e1-961cb38d8b59)

The query will run and, if successful, the data returned by your query will be displayed in the table underneath.

{% hint style="success" %}
:bulb: **Hints**

Here are a couple of quick commands you can use when writing your SQL:\
\
**Control + Space**\
Will give you the table and fields that are available to you.&#x20;

\
**Command + Enter**\
Shortcut to run the query
{% endhint %}

<br>

**You'll be assisted with messages**

![Example of message for sucessful query execution](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2FE9dmHDZeh9i0POt2H1hN%2Fimage.png?alt=media\&token=b40c18b9-21f6-425c-af2b-7da50601dfdc)

![Assisting messages might appear](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2FqvIeYrA5ugkCUdcQdHiG%2Fimage.png?alt=media\&token=766fcc99-2e49-44dd-95b1-5d3ccf711b39)

![Example of error message for unsuccessful query execution](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2Fh3D7rCB4q6qCuWhBZ5lD%2Fimage.png?alt=media\&token=762f67e3-e0e5-46ee-9c0d-8b3c981f7088)

#### **SAVE**

If you have any query that you'd like to re-visit regularly, you can save your SQL and revisit it at any point in time.

Note that any saved SQL will be stored and accessible from your account only.

![Save any SQL you want to re-visit](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2FkAihzSHIc1nnNhkb2d4u%2FSave%20Query.gif?alt=media\&token=800963ad-0aeb-407c-9de8-4ce8dbe55a94)

#### **LOAD FROM SAVED**

This allows you to access and load any of your saved SQL from the past.&#x20;

![Load a saved SQL](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2F6tEqWHkmm7MloJAoJeBK%2FLoad%20Query.gif?alt=media\&token=520a4f1e-341a-47a6-b36f-329be65d2447)
