美文网首页
mysql count统计多字段

mysql count统计多字段

作者: 左洁 | 来源:发表于2017-09-08 16:08 被阅读0次

纯属做一下笔记

order :订单表

id   account  order_status amount 

1    123           支付完成     20

2    245         待支付          30

3   567         支付失败        40

4  786          支付完成      50

select count( case where  o.order_status ='支付完成' then  'success' end ) success,

count( case where  o.order_status ='待支付' then  'success' end ) success,

count( case where  o.order_status ='支付失败' then  'success' end ) success,

count( id )  total from order o 

count也可以统计一张表多个字段

select cout(id),count(name) from table


相关文章

网友评论

      本文标题:mysql count统计多字段

      本文链接:https://www.haomeiwen.com/subject/wxxnjxtx.html