1. The from clause assembles data from different data sources;
2. The where clause filters record rows based on specified conditions;
3. The group by clause divides data into multiple groups;
4. Use Aggregate functions for computation;
5. Use the having clause to filter groups;
6. Calculate all expressions;
7. Use order by to sort the result set.
For example, in the student renewal table (temporarily recorded as tb_Grade), group the records whose "examinee name" is not empty by "examinee name" and filter the grouping results, select a score greater than 600 for the "Total score.
The standard order SQL statement is:
Select candidate name, max (total score) as max total score
From tb_Grade
Where examinee name is not null
Group by candidate name
Having max (total score)> 600
Order by max total score
In the preceding example, the SQL statement execution sequence is as follows:
(1) first, execute the FROM clause to assemble data FROM the tb_Grade table.
(2) execute the WHERE clause to filter data that is not NULL in the tb_Grade table.
(3) execute the group by clause to GROUP the tb_Grade table BY the "Student name" column.
(4) Calculate the max () Aggregation Function and calculate the maximum values in the total score by "total score ".
(5). Execute the HAVING clause to filter course scores greater than 600.
(7) Execute the order by clause to sort the final result BY "Max score.