starts_ with
On this page
Tests whether a string starts with another string.
Syntax
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.
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+-------------------+--------+
| event | events |
+-------------------+--------+
| payment_completed | 1 |
| payment_failed | 2 |
+-------------------+--------+