Default missing quantities with the ?? operator (kite shop)
Unknown quantities ship as 1 by policy. Add Ship Qty that uses Qty when it's known and 1 when it's null.
- Level
- beginner
- Time
- ~5 min
- Task
- Build the query
- Access
- Pro
Checking your access…
About this exercise
What you'll practise
Use the coalesce operator ?? to supply a default for null.
The scenario, sample data, step list, hints and solution open with Pro. Grading checks your query against hidden data as well as the visible sample, so a query that only fits the sample doesn't pass.
Input
- Orders (table)
- OrderID: text
- Customer: text
- Region: text
- Product: text
- Qty: number (nullable)
- UnitPrice: number
- OrderDate: text
- Status: text
Expected output columns
OrderID (text), Qty (number (some rows null)), Ship Qty (number)