- ******************************************************************************
- ************************************************************************************************************
- **********************************************************
- ********************************************************************************************
- ***************************************************
- *****************************************************
Table: amzn_employees
col_name | col_type -------------+------------------ employee_id | bigint first_name | text last_name | text joined_date | date salary | float
Sample results
first_name | last_name | lower ------------+-----------+---------------------- Jon | Snow | [email protected] Ned | Stark | [email protected]
Solution postgres
SELECT
first_name,
last_name,
LOWER(CONCAT(SUBSTRING(first_name, 1, 3), '.', SUBSTRING(COALESCE(last_name, 'SNOW'), 1, 5), '@amazon.com')) AS email
FROM amzn_employees;
Explanation
This query is selecting the first name, last name, and an email address for each employee in a table called "amzn_employees" in a PostgreSQL database.
The email address is created using the first 3 letters of the employee's first name, a period, the first 5 letters of their last name (or 'SNOW' if they don't have a last name), and "@mycompany.com".
The LOWER() function is used to convert the email address to lowercase characters.
Copied
Expected results
Your results