Business context
A catalog team prepares an export intended for a comparison page. It needs the business name and price, but not the technical identifiers or category. Explicitly choosing the columns reduces noise and stabilizes the contract between the query and the screen that consumes its result.
A catalog team prepares an export intended for a comparison page. It needs the business name and price, but not the technical identifiers or category. Explicitly choosing the columns reduces noise and stabilizes the contract between the query and the screen that consumes its result.
Skills practised
- Precisely define output columns
- Respect the order requested by the recipient
- Avoid SELECT* in a query intended for reuse
Available tables
Table produits
| Column | Type | Role |
|---|---|---|
id_produit | INTEGER | primary key |
produit | VARCHAR | product name |
categorie | VARCHAR | family |
prix | DECIMAL | price in € |
| prix | produit | categorie | id_produit |
|---|---|---|---|
| 89 | Keyboard | IT | 1 |
| 45 | Mouse | IT | 2 |
| 12 | Notebook | Office | 3 |
Your task
From the Products table, display the Product and Price columns, in that order.
For “Select the correct columns”, the success contract requires 3 rows, with the product, price columns at the requested level of detail. Control mark on the first line: product=Keyboard · price=89.
Build your reasoning
- First locate the requested table: products.
- Transform each expected piece of information into a column name: product then price.
- Place these columns after SELECT in the order of the expected result.
- Check that the query returns three rows and exactly two columns.
SELECT
-- columns to choose
FROM produits;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 |
|---|---|
| Keyboard | 89 |
| Mouse | 45 |
| Notebook | 12 |
Explained answer
Extra challenge
Extend the query
Add an alias prix_eur to the price column, then sort the products from most expensive to least expensive without adding a column to the result.