mysql count 中使用case when 带条件及去重
SELECT CASE (SELECT NOW() > '2019-02-12 16:48:00') WHEN 1 THEN '男' WHEN 2 THEN '女' ELSE '未知' END as ages
COUNT(CASE WHEN A.expire_time<{0} AND A.expire_time<>0 THEN A.expire_time END) AS disabled_total
对部分列去重
DISTINCT ucd.course_id,ucd.user_id and CASE WHEN ucd.kind=0 THEN ucd.kind END