Count Detailed:
COUNT (*) returns the total number of rows that exist in the table, including rows with a value of null, whereas count (column name) returns the total number of all rows except null in the table (columns with default values will also be counted).
Distinct the column name, the result will be the result of dropping the value null and repeating the data
Examples are shown below:
sql> Create table test
2 (
3 ename VARCHAR2 (10),
4 sal Number (4)
5);
The table is created.
sql> INSERT INTO test values (' Fxe1 ', 90);
1 rows have been created.
sql> INSERT INTO test (ename) values (' fxe2 ');
1 rows have been created.
sql> INSERT INTO test (ename) values (' fxe3 ');
1 rows have been created.
sql> INSERT INTO test (ename) values (' fxe4 ');
1 rows have been created.
sql> INSERT INTO test values (' fxe5 ', 80);
1 rows have been created.
sql> INSERT INTO test values (' fxe6 ', 80);
1 rows have been created.
Sql> SELECT * from test;
Ename SAL
---------- ----------
FXE1 90
Fxe2
Fxe3
Fxe4
Fxe5 80
Fxe6 80
sql> Select Count (*) from test;
COUNT (*)
----------
6
sql> Select count (sal) from test;
COUNT (SAL)
----------
3
sql> Select count (distinct sal) from test;
COUNT (Distinctsal)
------------------
2
sql> Select distinct sal from test;
SAL
----------
80
90
The difference between count (1) and COUNT (*) in Oracle