开发者社区 问答 正文

mysql 如何统计去重后的数量

mysql 如何统计去重后的数量

展开
收起
道月芬1 2021-10-15 18:17:05 568 分享 版权
1 条回答
写回答
取消 提交回答
  • mysql> select * from books;
    +------+--------+------+
    | name | author | jb   |
    +------+--------+------+
    | lkj  | NULL   | NULL |
    | lkj  | NULL   | NULL |
    | lkj  | NULL   | NULL |
    +------+--------+------+
    3 rows in set (0.00 sec)
    
    mysql> select count(distinct(name)) from books;
    +-----------------------+
    | count(distinct(name)) |
    +-----------------------+
    |                     1 |
    +-----------------------+
    1 row in set (0.22 sec)
    
    2021-10-15 18:17:49
    赞同 展开评论