首页 > 文章列表 > MySQL如何使用distinct()命令

MySQL如何使用distinct()命令

mysql distinct()
451 2023-05-02

distinct()

命令: distinct

作用:去重

应用场景:需要统计类型,状态,计算区分度时。

例子:

mysql> select count(distinct(name))/count(*) from t_base_user;
+--------------------------------+
| count(distinct(name))/count(*) |
+--------------------------------+
|    0.6667 |
+--------------------------------+
1 row in set (0.00 sec)