IF(expr1,expr2,expr3)
如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的返回值为expr2; 否则返回值则为 expr3。IF() 的返回值为数字值或字符串值,具体情况视其所在语境而定。
select
count(*) as total_pv,
count(submit_time) as complete_pv,
count(distinct if(submit_time is not null, exam_id, null))
from exam_record;