You are given a table products that contains information about various products including their unique ID, name, and description.
Task: Find all products whose description contains a valid serial number pattern.
Valid Serial Number Rules:
- Must start with the letters
SN(case-sensitive) - Followed by exactly 4 digits
- Must have a hyphen (
-) followed by exactly 4 digits - The serial number can appear anywhere within the description
Pattern Example: SN1234-5678
Return the result table ordered by product_id in ascending order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
product_id
PK
|
int | Unique identifier for each product |
product_name
|
varchar | Name of the product |
description
|
varchar | Product description that may contain serial numbers |
Input & Output
| product_id | product_name | description |
|---|---|---|
| 1 | Gaming Laptop | High-performance laptop with SN1234-5678 for gaming |
| 2 | Office Phone | Business phone without serial number |
| 3 | Tablet Pro | Professional tablet SN9876-5432 with stylus |
| 4 | Monitor | Display with invalid serial sn1111-2222 |
| 5 | Keyboard | Mechanical keyboard SN123-45678 extended |
| product_id | product_name | description |
|---|---|---|
| 1 | Gaming Laptop | High-performance laptop with SN1234-5678 for gaming |
| 3 | Tablet Pro | Professional tablet SN9876-5432 with stylus |
Products 1 and 3 have valid serial numbers (SN1234-5678 and SN9876-5432). Product 2 has no serial number, product 4 uses lowercase 'sn', and product 5 has incorrect digit counts (3 digits before hyphen, 5 after).
| product_id | product_name | description |
|---|---|---|
| 6 | Router | Network device SN12345-6789 with extra digit |
| 7 | Camera | Digital camera with SN0000-0001 serial |
| 8 | Printer | Laser printer SN1234_5678 with underscore |
| 9 | Speaker | Bluetooth speaker model contains no valid serial |
| product_id | product_name | description |
|---|---|---|
| 7 | Camera | Digital camera with SN0000-0001 serial |
Only product 7 has a valid serial number SN0000-0001. Product 6 has 5 digits before hyphen, product 8 uses underscore instead of hyphen, and product 9 has no valid pattern.
| product_id | product_name | description |
|---|---|---|
| 10 | Headphones | Wireless headphones with great sound quality |
| 11 | Mouse | Optical mouse for precise control |
| product_id | product_name | description |
|---|
No products contain valid serial numbers matching the SN####-#### pattern, so the result is empty.
Constraints
-
1 ≤ product_id ≤ 1000 -
product_nameanddescriptioncontain only printable ASCII characters -
Serial number pattern is case-sensitive and must be exactly
SNfollowed by 4 digits, hyphen, and 4 digits