175. Employees' email account

easy amazon

  • ******************************************************************************
  • ************************************************************************************************************
  • **********************************************************
  • ********************************************************************************************
  • ***************************************************
  • *****************************************************

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.

Expected results


More Amazon questions

ID Title Level FTPR
93 number of sales for each product this month amazon easy
20%
94 Top 3 products vs. bottom 3 products amazon medium
7%
95 Candidate products for subscription amazon hard
13%
108 Free premium membership amazon hard
16%
109 Top 3 most popular product categories amazon easy
11%
110 Most popular product by category amazon medium
12%
111 Second most popular product amazon medium
16%
112 Top 3 customers amazon easy
30%
113 Daily cumulative spend amazon easy
11%
114 Dod revenue change rate amazon easy
15%
115 Rolling average revenue amazon hard
28%
116 Top answers day by device amazon easy
14%
117 Rolling 7 days total answers amazon easy
35%
176 Employees' annual bonus amazon easy
12%
177 Purchases by platform report amazon medium
10%