首頁  >  文章  >  資料庫  >  MySQL如何使用distinct()指令

MySQL如何使用distinct()指令

WBOY
WBOY轉載
2023-05-27 10:02:181032瀏覽

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刪除