简体   繁体   English

我可以一起使用COUNT()和DISTINCT吗?

[英]Can I use COUNT() and DISTINCT together?

I would like to count the number of rows from a mysql table and not to include duplicate entries, 我想计算mysql表中的行数,而不是包含重复的条目,

Could I use distinct with count() ? 我可以使用distinct count()吗?

当然。

SELECT COUNT(DISTINCT column) FROM table;

What you need is the following: 您需要的是以下内容:

SELECT field_type_name, count(*) FROM fields GROUP BY field_type_name;

This will give you something like this: 这会给你这样的东西:

image   14
string  75
text     9
 SELECT COUNT(DISTINCT field) from Table

看到这个

SELECT count(DISTINCT column Name) as alias from table_Name;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM