Business context
The sales department wants to examine as a priority orders whose amount exceeds 50 TND. The descending ranking allows it to start with the most important files. This query separates two responsibilities: WHERE defines the scope and ORDER BY organizes only the retained rows.
Skills practised
- Translate a business threshold into a predicate WHERE
- Choosing between strict superior and superior or equal
- Produce a repeatable order with ORDER BY
Available tables
Table commandes
| Column | Type | Role |
|---|---|---|
id_commande | INTEGER | primary key |
id_client | INTEGER | customer concerned |
date_commande | DATE | date |
montant | DECIMAL | amount in TND |
| montant | id_client | id_commande | date_commande |
|---|---|---|---|
| 134 | 1 | 101 | 2026-07-03 |
| 89 | 2 | 102 | 2026-07-04 |
| 45 | 1 | 103 | 2026-07-06 |
Your task
Display id_commande and Amount for orders exceeding 50 TND. Sort the result by descending amount.
Build your reasoning
- Identify the relevant numeric column: amount.
- The word exceed imposes the strict > operator, so a command of 50 TND would be excluded.
- Request a sort on this same column with DESC.
- Verify that 134 precedes 89 and that 45 does not appear.
SELECT id_commande, montant
FROM commandes
WHERE -- your filter
ORDER BY -- your 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.
Shortcut: Ctrl/⌘ + Enter
The SQL environment will be prepared when you first run the query.
Expected result
| id_commande | montant |
|---|---|
| 101 | 134 |
| 102 | 89 |
Explained answer
Extra challenge
Extend the query
Keep only the two highest orders of those that exceed 50 TND and explain why LIMIT should come after ORDER BY.