27. 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.
Essential
SQL 0/33
Git 0/15
Spark 0/20
Snowflake 0/22
Python 0/24
Need more practice in this area? Explore more questions →
Apple
TCS
X
Accenture
Adobe
Google
LinkedIn
Samsung
Datadog
Wix
Dropbox
Meta
OpenAI
Hulu
Uber
DoorDash
Anthropic
Amazon
ActivisionBlizzard
Vercel
Crypto.Com
Zscaler
DeutscheBank
GoDaddy
BMW
PayPal
Snowflake
AMD
Twilio
Atlassian
JPMorgan
NVIDIA
IBM
Databricks
Coinbase
Cisco
Robinhood
Twitter
Microsoft
Palantir
Netflix
VMware
Cloudflare
Stripe
Capital One
Splunk
Intel
SAP
Tesla
GitHub
JaneStreet
Bloomberg
Salesforce
Elastic
CGI
UBS
GitLab
Ubisoft
Slack
Nintendo
EY
Kayak
Lyft
Airbnb
Walmart
Revolut
Visa
Okta
HashiCorp
Instacart
Mastercard