Write SQL and Python, run instantly in your browser, and track your progress.
You are a security analyst at Okta, a leading identity platform. For an upcoming compliance audit, you need to provide a standardized list of all user accounts. The report requires that all email addresses be normalized to lowercase and that the email domain be extracted for analysis of organizational sign-ups. User roles also need to be standardized to uppercase for consistent reporting.
Your task is to write a SQL query that transforms the users table to produce this standardized list.
The final report should be sorted alphabetically by the extracted email domain to help group users by their organization.
| Column Name | Type |
|---|---|
| user_id | INTEGER |
| org_id |
You are a security analyst at Okta, a leading identity platform. For an upcoming compliance audit, you need to provide a standardized list of all user accounts. The report requires that all email addresses be normalized to lowercase and that the email domain be extracted for analysis of organizational sign-ups. User roles also need to be standardized to uppercase for consistent reporting.
Your task is to write a SQL query that transforms the users table to produce this standardized list.
The final report should be sorted alphabetically by the extracted email domain to help group users by their organization.
| Column Name | Type |
|---|---|
| user_id | INTEGER |
| org_id |
| INTEGER |
| INTEGER |
| TEXT |
| TEXT |
| full_name | TEXT |
| full_name | TEXT |
| role | TEXT |
| role | TEXT |
| seat_type | TEXT |
| seat_type | TEXT |
| status | TEXT |
| status | TEXT |
| mfa_enabled | INTEGER |
| mfa_enabled | INTEGER |
| created_at | TEXT |
| created_at | TEXT |
| last_login | TEXT |
| last_login | TEXT |
| user_id | org_id | full_name | role | seat_type | status | mfa_enabled | created_at | last_login | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | feng.ferrari@vividdata.app | Feng Ferrari | owner |
| user_id | org_id | full_name | role | seat_type | status | mfa_enabled | created_at | last_login | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | feng.ferrari@vividdata.app | Feng Ferrari | owner |
| user_id | email_lower | email_domain | role_upper |
|---|---|---|---|
| 78 | miapark@azuredata.io | azuredata.io | OWNER |
| 79 | sandra@azuredata.io | azuredata.io | BILLING |
| 93 | hana.jones@coralindustries.tech | coralindustries.tech | OWNER |
| 94 | sebastian.park@coralindustries.tech | coralindustries.tech |
| user_id | email_lower | email_domain | role_upper |
|---|---|---|---|
| 78 | miapark@azuredata.io | azuredata.io | OWNER |
| 79 | sandra@azuredata.io | azuredata.io | BILLING |
| 93 | hana.jones@coralindustries.tech | coralindustries.tech | OWNER |
| 94 | sebastian.park@coralindustries.tech | coralindustries.tech |
Showing first 5 of 134 rows. Users with standardized emails and extracted domains sorted by domain.
Showing first 5 of 134 rows. Users with standardized emails and extracted domains sorted by domain.
Your final output should be a result set that meets the following requirements:
1. Transformations:
email column must be converted to all lowercase and aliased as email_lower.role column must be converted to all uppercase and aliased as role_upper.email_domain column must be created by extracting the part of the email address that comes after the @ symbol.@ symbol or is , the should be an empty string ().Your final output should be a result set that meets the following requirements:
1. Transformations:
email column must be converted to all lowercase and aliased as email_lower.role column must be converted to all uppercase and aliased as role_upper.email_domain column must be created by extracting the part of the email address that comes after the @ symbol.@ symbol or is , the should be an empty string ().| full |
| full |
| active |
| active |
| 1 |
| 1 |
| 2025-07-29 |
| 2025-07-29 |
| 2025-08-31 20:18:24 |
| 2025-08-31 20:18:24 |
| 2 | 1 | tao@vividdata.app | Tao Schneider | viewer | full | invited | 1 | 2025-08-18 |
| 2 | 1 | tao@vividdata.app | Tao Schneider | viewer | full | invited | 1 | 2025-08-18 |
| 3 | 1 | fang.al-farsi@vividdata.app | Fang Al-Farsi | member | full | invited | 0 | 2025-07-18 |
| 3 | 1 | fang.al-farsi@vividdata.app | Fang Al-Farsi | member | full | invited | 0 | 2025-07-18 |
| 4 | 1 | rennakamura@vividdata.app | Ren Nakamura | member | full | deleted | 0 | 2025-06-17 |
| 4 | 1 | rennakamura@vividdata.app | Ren Nakamura | member | full | deleted | 0 | 2025-06-17 |
| 5 | 1 | ychoi@vividdata.app | Yan Choi | admin | read_only | active | 1 | 2025-07-02 |
| 5 | 1 | ychoi@vividdata.app | Yan Choi | admin | read_only | active | 1 | 2025-07-02 |
| MEMBER |
| MEMBER |
| 96 | pwu@coralindustries.tech | coralindustries.tech | MEMBER |
| 96 | pwu@coralindustries.tech | coralindustries.tech | MEMBER |
NULLNULLemail_domainemail_domain''''2. Columns:
2. Columns:
user_idemail_loweremail_domainrole_upperuser_idemail_loweremail_domainrole_upper3. Ordering:
3. Ordering:
email_domain in ascending alphabetical order.user_id in ascending order.email_domain in ascending alphabetical order.user_id in ascending order.