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.
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 TND |
| 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.
Build your reasoning
- First locate the requested table: products.
- Transform each expected 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.
Shortcut: Ctrl/⌘ + Enter
The SQL environment will be prepared when you first run the query.
Expected result
| produit | prix |
|---|---|
| Keyboard | 89 |
| Mouse | 45 |
| Notebook | 12 |
Explained answer
Extra challenge
Extend the query
Add an alias prix_dt to the price column, then sort the products from most expensive to least expensive without adding a column to the result.