SQL Query Editor

An introduction to an SQL query editor for complicated questions

If you ever need to ask questions that can't be expressed using the query builder, you can use Clickhouse Compatible SQL.

Starting a new SQL query

To ask a question using a graphical query builder, go to Data Studio and click the + New button in the upper right of the main navigation bar and select SQL query.

After clicking SQL query, you'll see an editor where you can write and run queries in SQL.

SQL editor
    count(*) as num_bets,
    sum(stake_amount - win_amount) as ggr,
    max(stake_amount) as max_stake_amount
FROM bet_settlement
GROUP BY profile_uid;

Clicking the blue Run query button executes your query.


The returned table is the same as if the graphical query builder has been used.

Running query selections

You can run your SQL query by pressing ctrl + enter on Windows and Linux, or ⌘ + return on a Mac. You can also run only part of a query by highlighting the part you'd like to run before clicking the run button or using the run shortcut key.

Computed attributes requirements

If you wish to use your question to populate user-level computed attributes you have to follow specific rules:

  • The result dataset must include either profile_uid or user_id as one of the columns:
    • profile_uid is an ID of a unified user profile in Xremepush, which is recommended to use for performance reasons and is required if you wish your question to be computed in real-time.
  • Other columns in the dataset must represent individual attributes for those users:
    • The name of the column would appear as an attribute name in the single customer view.
    • At least one attribute column must be present.

See our computations guide to learn how to activate your computed attributes to make them available for usage in audiences, decisioning and personalisation.