Maybe we will not know the order of the keywords in the SQL statement writing process, and let us take it for fun. In this way, we may be happy at the end, however, our computer is not happy. We need to reschedule our messy SQL statements to achieve the expected results ~~~~~~ Let's take a look at the standard SQL parsing sequence to make our machines more happy and to make SQL statements more professional and practical !!
Standard SQL statement sequence:
1) from clause: Assemble data from different data sources. 2) on clause: Filter statements that do not meet the conditions, and then calculate statements that meet the conditions. 3) join clause: query data from these tables based on the relationship between columns in two or more tables. 4) WHERE clause: filter records based on the conditions we have set. 5) grouble by clause: divide data into two or more groups. 6) with cube or with rollup integrated function: Computing. 7) having statement: Screening group. 8) calculation expression. 9) order: sort the results 10) top words: specify the number of returned records. Example: In the student renewal table (temporarily marked as tb_grade), group the "examinee name" and filter the grouping results, select a person with a total score greater than 600. Therefore, the standard SQL statement is: Select examinee name, max (total score) as Max total score form tb_grade where examinee name is not null group by examinee name having max (total score)> 600 order by Max: in the preceding example, the SQL statement is executed in the following order: 1) execute the from statement and assemble data from the data source in the tb_grade table. 2) execute the where statement, filter data that is not null in the Table. 3) execute the group by clause to group the table by "examinee name". 4) Calculate the max () clustering function and evaluate the value by "total score". 5) execute the having statement and filter 6 with a total score greater than 600) Execute the order by statement and sort the final result by "Max total score ".