Count function usage in Oracle
Count is used to count the results of a query with several records
Example Table T_test
name |
Gender |
Age |
Wages |
Tom |
Man |
23 |
2000 |
John doe |
Woman |
34 |
|
Wang Wu |
Man |
25 |
1300 |
① Simple Application
Query: Select COUNT (*) from t_test;
Results: 3
Explanation: The above query returns the number of bars recorded in the table T_test.
Application of ② with where condition
Query: Select COUNT (*) from t_test where gender = ' male '
Results: 2
Explanation: The above query returns the number of records in the table t_test where the Gender field is "male."
③ the application of a field count
Query: Select count (payroll) from T_test
Results: 2
Explanation: The above query returns the number of records in the Payroll column in table T_test, excluding the results when a record's payroll is empty.
Application of ④ coordination distinct
Query: Select count (Distint sex) from t_test
Results: 2
Explanation: The above query returns the number of record bars for the select distinct gender from t_test result.