SQL statement and field quantity when the database calculates the number of different fields
Today, fields in Table A are queried, and different types of fields are collected;
1. select count (1) from A where strwhere collects statistics on the number of qualified rows
2. select count (filed) from A where strwhere collects statistics on the number of rows in the qualified columns, basically the same as above
The following are the highlights of today
3. when the field type is 0, 1, it is the simplest, but is commonly used for example: 1. male and female; 2. yes, no; When 0, 1 can be used as the positive and negative type of the type;
Select sum (filde1), sum (filde2) from A where strwhere
When multiple fields are queried and of a fixed type (typeA, typeB ....)
4. select sum (case when filed1 = typeA1 then 1 else 0 end), sum (case when filed2 = typeA2 then 1 else 0 end) from A where strwhere