MySQL统计一列中不同值的数量,查询为一条记录的方法:
1、select count(*) ,count(op='i' or null) from tablename where time>curdate();
2、select count(*) ,sum(if(op='i', 1, 0)) from tablename where time>curdate();
3、select count(*) ,sum(op='i') from tablename where time>curdate();
Oracle统计一列中不同值的数量,查询为一条记录的方法:
select count(*) ,count(case when op ='I' then '1' end) from tablename where time>trunc(sysdate);
1、select count(*) ,count(op='i' or null) from tablename where time>curdate();
2、select count(*) ,sum(if(op='i', 1, 0)) from tablename where time>curdate();
3、select count(*) ,sum(op='i') from tablename where time>curdate();
Oracle统计一列中不同值的数量,查询为一条记录的方法:
select count(*) ,count(case when op ='I' then '1' end) from tablename where time>trunc(sysdate);