← Back to lessons Beginner

SELECT, FROM and WHERE

Query a table and filter the relevant rows.

Beginner SQL syntax Finance and accounting scenario Related exercises

Objective

Select only the columns and rows needed for an analysis.

Exercise context

These exercises use filters to define a scope: customers in France, invoices above a threshold, purchases in a period or payments received.

Key concepts

  • SELECT specifies the columns to return.
  • FROM specifies the table to query.
  • WHERE filters rows using a condition.
  • Text values must be enclosed in single quotes.
  • Conditions can apply to amounts, dates, countries, categories or identifiers.

Syntax pattern

SELECT colonne1, colonne2
FROM table
WHERE condition;

Applied example

SELECT nom_client, secteur, pays
FROM clients
WHERE pays = 'France';

Common mistakes

  • Forgetting the FROM clause.
  • Using a column that does not exist in the table.
  • Forgetting quotes around text.
  • Confusing = and LIKE.

Recommended exercises