Make a mixed number/text code column all text (garden centre)
Product codes arrive as a mix of numbers (1001) and text (A-17, 0042). Make every code text.
- Level
- beginner
- Time
- ~5 min
- Task
- Build the query
- Access
- Free — no account needed
Loading the practice workspace…
About this exercise
What you'll practise
Convert a column that mixes value types to one type without losing information.
Greenway Garden Centre (fictional) merged two catalogues: the old one used numeric codes, the new one text codes.
Steps
Codeholds numbers for older products and text for newer ones (some with leading zeros).- Make
Codetext in every row: numbers become their digits (1001 → "1001"), and text codes stay exactly as they are ("0042" keeps its zeros). - Keep both columns,
CodeandProduct.
Your result must
- Every Code is text
- "0042" keeps its zeros
- No errors
Input
- Catalogue (table)
- Code: number or text
- Product: text
Expected output columns
Code (text), Product (text)
| Code | Product |
|---|---|
| 1001 | Gloves 3 |
| A-88 | Seed Tray 1 |
| 0081 | Hose 7 |