SELECT ... FROM
Select data
from a database.The data returned is stored in a result table, called the result-set.
ex. : SELECT column1, column2 FROM table_name
Note : peut ajouter un alias au nom des tables
pour simplifier l'écriture, exemple : FROM clients c, produits p
WHERE
Used to filter records. It is used to extract only those
records that fulfill a specified condition. ex. : WHERE Country = 'Mexico'
GROUP BY
Groups rows that have
the same values into summary rows, like "find the number of customers in
each country". It's is often used with aggregate
functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.
ORDER BY
Used to sort the result-set in ascending or descending order.
To sort the records in descending order, use the DESC keyword.
ex. : ORDER BY Country DESC
HAVING
Added to SQL because the WHERE keyword cannot be used
with aggregate functions.
Conditions
- The AND operator displays a record if all the conditions separated by AND are TRUE
- The OR operator displays a record if any of the conditions separated by OR is TRUE
- The NOT operator displays a record if the condition(s) is NOT TRUE
- The IN operator allows you to specify multiple values in a WHERE clause
- The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates
Operators
- The IIF() function returns true or false according to a condition
- The COUNT() function returns the number of rows that matches a specified criterion
- The AVG() function returns the average value of a numeric column
- The SUM() function returns the total sum of a numeric column
- The MIN() function returns the smallest value of the selected column
- The MAX() function returns the largest value of the selected column