Business context
An advisor prepares a selection of references above a budget threshold given by his client. Your answer must be verifiable by another person: respect the level of detail requested, use explicit aliases and control the number of records returned before drawing a business conclusion. The data is fictitious and is used for learning purposes only.
Skills practised
- WHERE
- Interpreting the result
- Checking the level of detail
Available tables
Table produits
| Column | Type | Role |
|---|---|---|
id_produit | INTEGER | unique identifier |
produit | VARCHAR | fictitious name |
categorie | VARCHAR | family |
marque | VARCHAR | fictitious brand |
prix | DECIMAL | selling price in TND |
cout | DECIMAL | unit cost in TND |
stock | INTEGER | units available |
| cout | prix | stock | marque | produit | categorie | id_produit |
|---|---|---|---|---|---|---|
| 55 | 89 | 12 | Atlas | Pro Keyboard | IT | 1 |
| 28 | 45 | 0 | Atlas | Air Mouse | IT | 2 |
| 4 | 12 | 80 | Carthage | A5 Notebook | Office | 3 |
| 20 | 34 | 8 | Medina | Focus Lamp | Office | 4 |
| 10 | 25 | 18 | Atlas | USB-C Cable | Accessories | 5 |
| 35 | 58 | 14 | Kairouan | Urban Bag | Travel | 6 |
| 76 | 120 | 6 | Medina | Vision Webcam | IT | 7 |
| 42 | 75 | 42 | Carthage | Monitor Stand | Office | 8 |
Your task
Show product and price for products costing at least 50 TND, from most expensive to least expensive.
Build your reasoning
- Rephrase the mission and its level of detail: Display product and price for products costing at least 50 TND, from most expensive to least expensive.
- Locate the necessary columns in products before applying WHERE · ORDER BY.
- First build the structure that must return product, price, then add the filters or calculations.
- Check the 4 expected lines and explain a value with the source data.
SELECT produit, prix
FROM produits
WHERE -- inclusive threshold
ORDER BY -- sorting;Browser-based SQL environment
Interactive SQL editor
Run a read-only query on this exercise's fictional data. Nothing is sent to SQL.tn.
Expected result
| produit | prix |
|---|---|
| Vision Webcam | 120 |
| Pro Keyboard | 89 |
| Monitor Stand | 75 |
| Urban Bag | 58 |
Explained answer
Extra challenge
Extend the query
Add a second alphabetical criterion to stabilize the ranking in the event of a price tie. Describe in one sentence the control you would add before sharing this result in a report.