diff --git a/README.md b/README.md index 093df20..a942324 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/leetcode/easy/3436. Find Valid Emails.sql b/leetcode/easy/3436. Find Valid Emails.sql new file mode 100644 index 0000000..ef3ff8a --- /dev/null +++ b/leetcode/easy/3436. Find Valid Emails.sql @@ -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