AnalystPath

Pallets With a Well-Formed Tracking Code

SQLEasyJunior level~15 min

Problem

Table: `pallets`

```text
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| pallet_id | int |
| zone_label | varchar |
| note | varchar |
+--------------+---------+
pallet_id is the primary key for this table.
Each row describes a storage pallet and a free-text receiving note.
```

A warehouse stamps a tracking code on a pallet using the format `PL` followed by exactly four digits, then a forward slash, then exactly three digits — for example `PL2048/917`. A code with too few or too many digits in either group is invalid, and the digit group must not be immediately followed by another digit.

Write a query to return every pallet whose `note` contains a well-formed tracking code. Return `pallet_id`, `zone_label`, and `note`, sorted by `pallet_id` ascending.

Tables

Example rows — the live problem includes the full dataset.

pallets
pallet_idzone_labelnote
1Dock NorthReceived pallet PL2048/917 this morning
2Cold StoreTagged PL0007/300 awaiting count
3Dock SouthStamp PL2048/9175 was misprinted

Expected output

Your answer should return 3 rows with the columns pallet_id, zone_label, note.

Starter code (SQL)

SELECT *
FROM pallets;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions