SELECT up.device_id, up.university, IF(cid IS NULL,0,cid), IF(cr IS NULL,0,cr) AS question_cnt FROM user_profile up LEFT JOIN (SELECT &n...