MySql cmd下的学习笔记 —— 有关select的操作(max, min等常见函数)

先把之前建的goods表找到

找到最贵的本店价(max)

找到最便宜的本店价(min)

 

查出一共还有多少商品(count)

查看商品价的平均价(avg)

查看本店有多少种商品

 

当count(*)时 输出的时绝对行数

而count(列名)时,输出行数为不为null的

mysql> select * from test4;
+------+------+
| id   | name |
+------+------+
|    1 | Lili |
|    2 | NULL |
+------+------+
2 rows in set (0.00 sec)

mysql> select count(*) from test4;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (0.00 sec)

mysql> select count(name) from test4;
+-------------+
| count(name) |
+-------------+
|           1 |
+-------------+
1 row in set (0.00 sec)
count()的区别

猜你喜欢

转载自www.cnblogs.com/abc23/p/9400698.html