开发者

Can I use COUNT() and DISTINCT together?

开发者 https://www.devze.com 2023-01-31 03:30 出处:网络
I would like to count the number of rows from a mysql table and not to include duplicate en开发者_JAVA技巧tries,

I would like to count the number of rows from a mysql table and not to include duplicate en开发者_JAVA技巧tries,

Could I use distinct with count()?


Sure.

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

See this.


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号