Current location - Loan Platform Complete Network - Big data management - How does SQL count numbers?
How does SQL count numbers?
Method 1:

Select SUM +SUM as the total number of records, SUM (correct number), SUM (error number)?

From (?

Choose to count (1) the correct number, 0 the wrong number?

Tuberculosis?

Where the status = 1.

Joint ownership?

Choose the correct number of 0 and count the number of (1) errors?

Tuberculosis?

Where state =0) a

Method 2:

Select count( 1) records total number, sum (when status =1then1else 0 end) correct number, sum (when status = 0 then1else 0 end) error number from T.

1, statistical average:

SELECT AVG(column) FROM tb_name This SQL syntax is used to calculate the average number of fields of a specific numeric type. You cannot have multiple fields in AVG (). Although you can perform types such as strings, it is meaningless.

2. Sum of statistical data:

SELECT SUM(column) FROM tb_name This SQL syntax is used to calculate the sum of field values of a specific numeric type. There cannot be multiple fields in sum (), and types such as strings can be executed, but it is meaningless.

3. Statistical maximum data:

SELECT MAX(column) FROM tb_name This SQL syntax is used to calculate the maximum value of a numeric type field. Max () cannot contain multiple fields.

4. Minimum statistics:

SELECT MIN(column) FROM tb_name? SQL syntax is used to calculate the minimum value of numeric type fields, and there cannot be multiple fields in min ().