20191216记录:有一想业务是统计文章通过数,未通过数和总文章数,本来是想写三条Sql语句的,但是想起来 mysql 有 case when ,记录一下,以备不时之需
SELECT
count( CASE WHEN verify = 1 THEN 1 END ) AS 'pass',
count( CASE WHEN verify = 2 THEN 1 END ) AS 'back',
count( * ) AS `all`
FROM
article_verify
20191216记录:有一想业务是统计文章通过数,未通过数和总文章数,本来是想写三条Sql语句的,但是想起来 mysql 有 case when ,记录一下,以备不时之需
SELECT
count( CASE WHEN verify = 1 THEN 1 END ) AS 'pass',
count( CASE WHEN verify = 2 THEN 1 END ) AS 'back',
count( * ) AS `all`
FROM
article_verify