zoukankan      html  css  js  c++  java
  • MYSQL统计

    mysql统计同一字段下,不同值的总数的方法:

    basebandBoard为字段,BPN2和CCE1等是为字段的多个值,这里进行统计。

    方法一:

    use gc;
    select basebandBoard,count(basebandBoard) co from four where basebandBoard='CCE1';
    select basebandBoard,count(basebandBoard) co from four where basebandBoard='BPN2';
    select basebandBoard,count(case when basebandBoard='BPN2' then 1 end) as BPN2,
    count(case when basebandBoard='CCE1' then 1 end) as CCE1,
    count(case when basebandBoard='BPP1' then 1 end) as BPP1
    from four
    group by basebandBoard;

     效果:

    方法二:

    select count(if(basebandBoard='BPN2',basebandBoard,null)),count(if(basebandBoard='CCE1',basebandBoard,null)),count(if(basebandBoard='BPP1',basebandBoard,null)) from four;

    效果:【这样的显示可以有助于知道if的用法,后续实际使用可以取别名】

    命别名后:

    select count(if(basebandBoard='BPN2',basebandBoard,null)) BPN2,count(if(basebandBoard='CCE1',basebandBoard,null)) BPN2,count(if(basebandBoard='BPP1',basebandBoard,null)) BPP1 from four;

    效果:

  • 相关阅读:
    js 音乐播放器
    音频播放器在chrome浏览器,play报错
    CSS多行文字超出隐藏加省略号
    css 清楚浮动的几种方式
    npm -g -D -s的区别
    electron-vue初始桌面应用
    vue 关闭浏览器
    webpack基础
    京东数科-百度BCOT---面试
    HTTP面试题
  • 原文地址:https://www.cnblogs.com/ciscolee/p/11178864.html
Copyright © 2011-2022 走看看