# SQL Filter

CrossEngage's Predictions Platform provides various filtering options to add or remove Customers from certain Selections. This includes customer lists uploaded as files (blocklists and allowlists) or other Selections. These methods can be quite useful to restrict Selections, but can be time-intensive and limited in capability.

Hence the Platform allows you to enter a Custom SQL filter when creating Prediction Models.

### Target Variable / Target Group

While setting up the Model, you can find filter options In the Target Variable or Target Group settings. Here you can write a SQL filter with the help of our application, hence you do not need to know SQL.

<figure><img src="/files/mkWHB0SWpQvBTWkCSVlT" alt=""><figcaption></figcaption></figure>

### Row Filters

You can also add filters in the "Row Filters" section under "Advanced Configuration". Row filters are applied to the data before preparation for the model; hence these filters can reduce the amount of the data going into the system and reduce the time they take to process. These filters are recommended if you want to optimize the Model's runtime or if certain data should be excluded from the analysis.

<figure><img src="/files/sdH7Ndx5cunN6aMx4m7h" alt=""><figcaption></figcaption></figure>

### Data Types

The fields can have the following data types:

* **Numeric:** Whole numbers or floating point numbers
* **Strings:** Any character such as digits, letters, special characters, etc. Strings are written in 'single quotes'.
* **Date & Time**
* **Boolean:** True or False

### Operators

Operators can be used to compare or combine different values or expressions:

* **Arithmetic Operators:** These can be applied to numeric values: +, -, \*, /, etc.
* **Comparison Operators:** These compare values ​​between two expressions and return a boolean value: =, >, <, !=, IN, BETWEEN, LIKE etc.
* **Logical Operators:** Boolean operators, which can combine different expressions and values ​​together: AND, OR, etc.

{% hint style="warning" %}
Remember to use the correct case when using filters. A simple way to avoid case-sensitivity errors is to keep all values stored in the data tables in lowercase.
{% endhint %}

### Wildcards

Wildcards are placeholder characters, which can be added to a string when a certain part of string is unknown or not fixed. Wildcards are used with the SQL `LIKE` operator to find similar strings.

* **Underscore:** Underscore (\_) can be used to replace a single unknown character in a string.
* **Percent:** Percent (%) can be used to replace a series of unknown characters, of any length.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.crossengage.io/data-and-engagement-platform/prediction-models/sql-filter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
