EasyString Functions

LENGTH and CHAR_LENGTH

The query

SQL
SELECT
  email,
  LENGTH(email) AS char_count,
  POSITION('@' IN email) AS at_position,
  SUBSTRING(email FROM POSITION('@' IN email) + 1) AS domain
FROM employees
WHERE status = 'active';
Tested against PostgreSQL 16

Note

POSITION returns 1-based index of substring. SUBSTRING extracts portions of strings.

Tables referenced