计算包含相同值的行数 [英] Count number of rows which contains same value
本文介绍了计算包含相同值的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是 MySQL 查询来计算包含相同值的总行数.例如:
What is the MySQL query to count the total number of rows which contains the same value. For example:
考虑一个包含所有动物名称的表 animal
.如果表中有 5 行包含值 name
作为 'cow'
那么它的查询是什么?
Consider a table animal
which contains all animal names. If there are 5 rows in the table which contains the value name
as 'cow'
then what would be the query for it?
推荐答案
SELECT animal_name,
COUNT(*) AS animal_count
FROM animal_table
GROUP BY animal_name;
这篇关于计算包含相同值的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文