SQL基础(一零)---Count

来源:互联网 发布:男士真皮手套品牌 知乎 编辑:程序博客网 时间:2024/06/02 04:29

查询员工总数:

mysql> select count(*), count(fnumber) from t_employee;+----------+----------------+| count(*) | count(fnumber) |+----------+----------------+|        8 |              8 |+----------+----------------+1 row in set

NULL值对COUNT函数的影响:

mysql> insert into t_employee(fnumber,fage,fsalary) values('IT002',27,2800);Query OK, 1 row affectedmysql> select * from t_employee;+----------+-------+------+---------+| fnumber  | fname | fage | fsalary |+----------+-------+------+---------+| DEV001   | Tom   |   25 | 8300    || DEV002   | Jerry |   28 | 2300.8  || HR001    | Jane  |   23 | 2200.88 || HR002    | Tina  |   25 | 5200.36 || IT001    | Smith |   28 | 3900    || IT002    | NULL  |   27 | 2800    || SALES001 | John  |   23 | 5000    || SALES002 | Kerry |   28 | 6200    || SALES003 | Stone |   22 | 1200    |+----------+-------+------+---------+9 rows in setmysql> select count(*), count(fnumber),count(fname) from t_employee;+----------+----------------+--------------+| count(*) | count(fnumber) | count(fname) |+----------+----------------+--------------+|        9 |              9 |            8 |+----------+----------------+--------------+1 row in set


0 0