Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ Useful for preparing for technical interviews and improving your SQL skills.
- [1965. Employees With Missing Information](./leetcode/easy/1965.%20Employees%20With%20Missing%20Information.sql)
- [1978. Employees Whose Manager Left the Company](./leetcode/easy/1978.%20Employees%20Whose%20Manager%20Left%20the%20Company.sql)
- [2356. Number of Unique Subjects Taught by Each Teacher](./leetcode/easy/2356.%20Number%20of%20Unique%20Subjects%20Taught%20by%20Each%20Teacher.sql)
- [3436. Find Valid Emails](./leetcode/easy/3436.%20Find%20Valid%20Emails.sql)
2. [Medium](./leetcode/medium/)
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
- [180. Consecutive Numbers](./leetcode/medium/180.%20Consecutive%20Numbers.sql)
Expand Down
29 changes: 29 additions & 0 deletions leetcode/easy/3436. Find Valid Emails.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Question 3436. Find Valid Emails
Link: https://leetcode.com/problems/find-valid-emails/description/?envType=problem-list-v2&envId=database

Table: Users

+-----------------+---------+
| Column Name | Type |
+-----------------+---------+
| user_id | int |
| email | varchar |
+-----------------+---------+
(user_id) is the unique key for this table.
Each row contains a user's unique ID and email address.
Write a solution to find all the valid email addresses. A valid email address meets the following criteria:

It contains exactly one @ symbol.
It ends with .com.
The part before the @ symbol contains only alphanumeric characters and underscores.
The part after the @ symbol and before .com contains a domain name that contains only letters.
Return the result table ordered by user_id in ascending order.
*/

SELECT
user_id,
email
FROM Users
WHERE email ~ '^([a-zA-Z0-9]?[_]?[a-zA-Z0-9]?)*@[a-zA-Z]+\.com$'
ORDER BY user_id ASC