Skip to content

task: #3465 #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2025
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 @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions leetcode/easy/3465. Find Products with Valid Serial Numbers.sql
Original file line number Diff line number Diff line change
@@ -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