# SQL Block

<figure><img src="https://1875572357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzP7hFWzU2Jj7xMbv2nyp%2Fuploads%2Fgit-blob-97dea59754156c8b438aa7c571e19081daebcb3c%2Fsql.png?alt=media" alt=""><figcaption></figcaption></figure>

SQL Block is a block within the notebook that allows executing SQL.

Within the SQL Block, you can edit and run queries, display the results, view statistical information, and create charts.

## Key Features

* Professional SQL Editor with Powerful Support:
  * Includes features like function and reserved word suggestions, auto-completion, syntax highlighting, and formatting.
* Instant Result Preview:
  * Execute queries and preview results in real-time using Ctrl + Return.
* Table Search:
  * Use the `/` command within SQL blocks to search for tables within datasets and their connections. You can also search by metadata and field names in the catalog.
* Code Snippets:
  * Create code snippets for personal use or share them across the workspace. Customize settings like triggers and cursor positions after completion.
* Rich Shortcut Keys:
  * Utilize a various shortcut keys, which can also be customized for personal use.
* SQL Chain
  * Reference other SQL Blocks within an SQL Block. This helps manage complex SQL by breaking it down into more understandable and reusable components.
* Field Stats:
  * Easily retrieve statistical information for each field, such as data type, presence of null values, unique count, average value, quantile, frequency, and histogram.

## How to Use

* Creating an SQL Block:
  * While focused on an empty paragraph in a Doc Page, use the slash command (`/`) to select and create an SQL Block.
* Creating References:
  * Within the SQL Block, you can use the slash command to create references to other SQL Blocks and tables.
  * You can also create references to Parameters and Saved queries.
