# starts\_with

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/string/starts_with)

Tests whether a string starts with another string.

## Syntax

```scopeql
starts_with(<string>, <prefix>)
```

## Arguments

| Argument   | Type     | Description      |
| ---------- | -------- | ---------------- |
| `<string>` | `string` | String to test.  |
| `<prefix>` | `string` | Prefix to match. |

## Returns

Returns `boolean`: TRUE if `<string>` starts with `<prefix>`, otherwise FALSE. Returns NULL if either input is NULL. An empty `<prefix>` matches every non-NULL string.

## Examples

Select the payment event family before aggregating event names.

```scopeql
VALUES
    ('payment_failed'), ('checkout_started'), ('payment_completed'), ('payment_failed')
SELECT $0 AS event
WHERE starts_with(event, 'payment_')
GROUP BY event
AGGREGATE count() AS events
ORDER BY event
```

```text
+-------------------+--------+
| event             | events |
+-------------------+--------+
| payment_completed | 1      |
| payment_failed    | 2      |
+-------------------+--------+
```
