诀情式浮生若梦吧 关注:23贴子:422
  • 1回复贴,共1

【MYSQL】偶尔来的笔记

只看楼主收藏回复

偶尔的感悟,偶尔的记录


IP属地:浙江1楼2018-04-18 10:12回复
    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);


    IP属地:浙江2楼2018-04-18 10:19
    回复