c# 中如何统计数据库中某字段相同内容的条数

来源:百度知道 编辑:UC知道 时间:2024/05/18 09:34:09
比如 数据库字段为abcd 想统计值为1的记录有多少条,如何写?谢谢,本人菜鸟,最好详细些!

cmd.commandText="select count(*) from sometable where abcb=1";
执行语句,读取这个值 就行了。

select count(*) from 表名 where abcd=1

select count(*) from table where abcd=1

select count(abc) ,abc from 表 where abc in (select distinct abc from 表) group by abc
这个应该符合你的,根据abc的不同值分别统计它的数量。

select count(*) from table where abcd=1