String Pattern Matching Using LIKE
Beginner Mode
Objective
Write an SQL query to fetch the names, department names, email addresses, and position levels of employees. The query should filter employees based on the following criteria:
- Employee names start with the letter 'A'.
- Employee email addresses contain the substring '@tech'.
- Employee position levels contain the word 'Senior'.
The results should be ordered by employee names in ascending order.
Additional information
- Assume the existence of two tables:
employeesanddepartments. - The
employeestable contains the columns:id,name,department_id,email, andposition_level. - The
departmentstable contains the columns:id,name, andlocation. - Join the two tables on the
department_idcolumn from theemployeestable and theidcolumn from thedepartmentstable. - The results should only include columns:
name,department,email, andposition_level.
Constraints:
- The length of
namewill be within [1, 100]. - The length of
emailwill be within [5, 100]. - The length of
position_levelwill be within [5, 50]. - The number of rows in the
employeesanddepartmentstables will not exceed 1000.
Examples
Example 1:
Output:
Input:
| departments | ||
|---|---|---|
| id | location | name |
| 1 | NYC | Engineering |
| 2 | SF | Product |
| 3 | Chicago | Sales |
| employees | ||||
|---|---|---|---|---|
| department_id | id | name | position_level | |
| 1 | [email protected] | 1 | Alice Smith | Senior Developer |
| 2 | [email protected] | 2 | Andrew Brown | Senior Manager |
| 1 | [email protected] | 3 | Amanda Lee | Senior Architect |
| 1 | [email protected] | 4 | Bob Wilson | Senior Developer |
| 3 | [email protected] | 5 | Aaron Davis | Senior Executive |
| 2 | [email protected] | 6 | Anna White | Junior Developer |
| department | name | position_level | |
|---|---|---|---|
| Engineering | [email protected] | Alice Smith | Senior Developer |
| Engineering | [email protected] | Amanda Lee | Senior Architect |
Code Environment
Sign in or try as guest to run your code.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
Apple