首页  >  文章  >  数据库  >  MySQL如何使用distinct()命令

MySQL如何使用distinct()命令

WBOY
WBOY转载
2023-05-27 10:02:181029浏览

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)

以上是MySQL如何使用distinct()命令的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:yisu.com。如有侵权,请联系admin@php.cn删除