▶ sort query 1. Syntax

Order by... order by... order by...

2. Sorting mode

1.ASC: ascending by default.

2.DESC: descending order.

3. 【 descending order 】

4. Example 2: Ascending and Multiple Expression rules

5. Precautions

When multiple sorting expressions are used, pay attention to the order of precedence. If the values in the first sorting expression are the same, use the second sorting expression. If the values in the second sorting expression are the same, use the next expression in turn.

Take a column of data as a whole and compute vertically.

2. Key words

  1. Count: Indicates the number to be calculated. Note: Generally select a non-empty column: primary key.
  2. Max: Calculates the maximum value.
  3. Min: Calculates the minimum value.
  4. Sum: calculates the sum.
  5. Avg: Calculate the average value.

3. Syntax select keyword (column name);

4. How to write this expression?

5. 【 note that the value is null】

6. Precautions 1. Null values must be excluded from the calculation of aggregate functions. Solution: (1) The first solution: select a column that does not contain empty space for calculation. (2) The second option: select ifNULL () statement for calculation. Recommended.

▶ GROUP query and HAVING statement

Syntax group by;

2. [including the difference between where and having]

1. The queried fields must be grouped fields and aggregate functions. None of the other fields can. 2. Where and having

3. 【 grammar Basics 】

4. 【 Set the conditions for grouping 】

5. Group first and then qualify.

1. Syntax limit start index, number of entries per page

2. 【 grammar application 】

3. How to define the initial index [formula]

Start index = (current page number -1) * number of pages to display per page

4. 【 formula application 】

5. Precautions

The syntax keyword limit is a mysql dialect used to perform paging operations