开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜