# NQL editor

The NQL editor offers a web-based user interface allowing you to write and execute investigations using Nexthink Query Language (NQL).

The embedded syntax editor allows you to adjust existing queries or create new ones from scratch. The results help you investigate issues and problems faced by employees in your organization.

## Querying data using the NQL editor <a href="#nqleditor-accessingthenqleditor" id="nqleditor-accessingthenqleditor"></a>

{% hint style="info" %}
Install the [Nexthink Library Investigations starter](https://docs.nexthink.com/platform/library-packs/it-operations/investigations-starter-pack) pack with predefined investigations to quickly gain insights on common issues without manually writing NQL queries, or using Nexthink Assist or Visual editor to query data.
{% endhint %}

1. Select **Investigations** from the main menu to create or edit an existing investigation. The [Visual editor](https://docs.nexthink.com/platform/user-guide/investigations/creating-investigations/visual-editor) tab opens by default.
   * **I**f needed, click the **New investigation** button in the top-right corner of the page to open a new investigation tab.
2. Switch to the **NQL editor** mode and start writing your NQL query.
   * Refer to the [Nexthink Query Language (NQL)](https://docs.nexthink.com/platform/understanding-key-data-platform-concepts/nexthink-query-language-nql) documentation page for more information about NQL syntax and capabilities.
   * Access the [NQL data model](https://docs.nexthink.com/platform/understanding-key-data-platform-concepts/nql-data-model) documentation page using the question mark icon (**?**) in the bottom-right corner of the NQL editor.

Alternatively, with the support of [Nexthink Assist](https://docs.nexthink.com/platform/user-guide/search-and-nexthink-assist/using-nexthink-assist#query-data-with-assist), you may build investigation queries without any prior knowledge of **Visual editor** or NQL.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-fb0f187ac2c7d836e39e4dfbf413b2f584641c06%2FNQLeditor_01.png?alt=media" alt="Querying data using the NQL editor."><figcaption></figcaption></figure>

3. Select **Run** to execute the query and generate results in a **Results** tab.
4. If needed, use the buttons available in NQL Editor, next to **Run**:
   * **Copy query**
   * **Paste from clipboard**
   * **Clear query**
5. Resize the NQL editor vertically by dragging its bottom edge up or down. Click **Reset height** to restore the default size.

{% hint style="info" %}
The maximum length of an NQL query is 16000 characters.
{% endhint %}

### Querying connection events for Network view <a href="#visualeditor-selectingconnectioneventsfornetworkview" id="visualeditor-selectingconnectioneventsfornetworkview"></a>

From the Investigations page:

1. Switch to the **NQL editor** mode.
2. **Run** an NQL query to investigate `connection.events` to enable the **Network** tab.
3. Open the **Network** tab for Network view visualization.

See the following `connection.events` query example:

```
connection.events during past 7d
| summarize no_of_binaries = binary.count(), no_of_devices = device.count(), no_of_users = user.count(), no_of_applications = application.application.name.count(), no_of_network_applications = application.network_application.name.count()
| list no_of_binaries, no_of_devices, no_of_users, no_of_applications, no_of_network_applications
```

{% hint style="info" %}
Refer to the [Network view](https://docs.nexthink.com/platform/user-guide/network-view) documentation to learn how to identify and troubleshoot network-related issues.
{% endhint %}

### Querying chart visualizations of investigation results

From the Investigations page:

1. Switch to the **NQL editor** mode.
2. **Run** a NQL query compatible with [line charts](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/line-chart) and [bar charts](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/bar-chart) NQL structure.
3. Click the **Toggle to chart view** button in the top-right corner of the investigations result table for data visualization.

See the bar chat query example below.

{% hint style="info" %}
Charts created from queries in the NQL editor may [not be supported](https://docs.nexthink.com/platform/user-guide/investigations/visual-editor#visualeditor-visualeditorunsupportednqlstatements) by the Visual editor.
{% endhint %}

```
devices during past 7d
| summarize no_of_devices = count() by device.hardware.model
| list no_of_devices, device.hardware.model
```

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-d849c13166863183a5ae6fa45b56ba5c466a4c15%2FNQLeditor_02.1.png?alt=media" alt="Querying bar chat visualization in NQL editor."><figcaption></figcaption></figure>

***

RELATED TOPIC

* [Visual editor](https://docs.nexthink.com/platform/user-guide/investigations/creating-investigations/visual-editor)
* [Roles](https://docs.nexthink.com/platform/user-guide/administration/account-management/roles)
