diff --git a/README.md b/README.md index c61d7e0..de4781a 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Have a good contributing! - [1378. Replace Employee ID With The Unique Identifier](./leetcode/easy/1378.%20Replace%20Employee%20ID%20With%20The%20Unique%20Identifier.sql) - [1407. Top Travellers](./leetcode/easy/1407.%20Top%20Travellers.sql) - [1484. Group Sold Products By The Date](./leetcode/easy/1484.%20Group%20Sold%20Products%20By%20The%20Date.sql) + - [1517. Find Users With Valid E-Mails](./leetcode/easy/1517.%20Find%20Users%20With%20Valid%20E-Mails.sql) - [1527. Patients With a Condition](./leetcode/easy/1527.%20Patients%20With%20a%20Condition.sql) - [1581. Customer Who Visited but Did Not Make Any Transactions](./leetcode/easy/1581.%20Customer%20Who%20Visited%20but%20Did%20Not%20Make%20Any%20Transactions.sql) - [1587. Bank Account Summary II](./leetcode/easy/1587.%20Bank%20Account%20Summary%20II.sql) diff --git a/leetcode/easy/1517. Find Users With Valid E-Mails.sql b/leetcode/easy/1517. Find Users With Valid E-Mails.sql new file mode 100644 index 0000000..321ea53 --- /dev/null +++ b/leetcode/easy/1517. Find Users With Valid E-Mails.sql @@ -0,0 +1,32 @@ +/* +Question 1517. Find Users With Valid E-Mails +Link: https://leetcode.com/problems/find-users-with-valid-e-mails/description/?envType=study-plan-v2&envId=top-sql-50 + +Table: Users + ++---------------+---------+ +| Column Name | Type | ++---------------+---------+ +| user_id | int | +| name | varchar | +| mail | varchar | ++---------------+---------+ +user_id is the primary key (column with unique values) for this table. +This table contains information of the users signed up in a website. Some e-mails are invalid. + + +Write a solution to find the users who have valid emails. + +A valid e-mail has a prefix name and a domain where: + +The prefix name is a string that may contain letters (upper or lower case), digits, underscore '_', period '.', and/or dash '-'. The prefix name must start with a letter. +The domain is '@leetcode.com'. +Return the result table in any order. +*/ + +SELECT + user_id, + name, --noqa: RF04 + mail +FROM Users +WHERE mail ~ '^[a-zA-Z]+([a-zA-Z0-9]?[._-]?[a-zA-Z0-9]?)*@leetcode\.com$'