diff --git a/README.md b/README.md index 1ef55db..709a704 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ Useful for preparing for technical interviews and improving your SQL skills. - [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) + - [3465. Find Products with Valid Serial Numbers](./leetcode/easy/3465.%20Find%20Products%20with%20Valid%20Serial%20Numbers.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/3465. Find Products with Valid Serial Numbers.sql b/leetcode/easy/3465. Find Products with Valid Serial Numbers.sql new file mode 100644 index 0000000..07dce81 --- /dev/null +++ b/leetcode/easy/3465. Find Products with Valid Serial Numbers.sql @@ -0,0 +1,31 @@ +/* +Question 3465. Find Products with Valid Serial Numbers +Link: https://leetcode.com/problems/find-products-with-valid-serial-numbers/description/?envType=problem-list-v2&envId=database + +Table: products + ++--------------+------------+ +| Column Name | Type | ++--------------+------------+ +| product_id | int | +| product_name | varchar | +| description | varchar | ++--------------+------------+ +(product_id) is the unique key for this table. +Each row in the table represents a product with its unique ID, name, and description. +Write a solution to find all products whose description contains a valid serial number pattern. A valid serial number follows these rules: + +It starts with the letters SN (case-sensitive). +Followed by exactly 4 digits. +It must have a hyphen (-) followed by exactly 4 digits. +The serial number must be within the description (it may not necessarily start at the beginning). +Return the result table ordered by product_id in ascending order. +*/ + +SELECT + product_id, + product_name, + description --noqa +FROM products +WHERE description ~ '\ySN[0-9]{4}\-[0-9]{4}\y' +ORDER BY product_id ASC pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy