我的数据库测试表结构如下,现在统计gid大于1的数量
count()函数统计数据表中包含的记录行的总数,或者根据查询结果返回列中包含的数据行数。其使用方法有两种:
select count(IF(gid>1,1,null)) from goods;
select count(case when gid>1 then 1 else null end) from goods;
使用count()函数实现条件统计的基础是对于值为NULL的记录不计数