当前位置:网站首页>MySQL null value processing and value replacement

MySQL null value processing and value replacement

2022-07-07 04:24:00 Data analysis of financial Xiaobai

SELECT user_profile.device_id,user_profile.university,IFNULL(B.question,0),IFNULL(B.RIGHT_QUESTION,0) FROM user_profile LEFT JOIN (
SELECT device_id, COUNT(*) AS question,sum((case when result='right' then 1 else 0 end)) as RIGHT_QUESTION 
FROM question_practice_detail WHERE month(date)=8 GROUP BY device_id) 
AS B ON user_profile.device_id=B.device_id WHERE user_profile.university=" Fudan University " 

Comprehensive operation

SELECT difficult_level,sum(ar)/count(*) AS RATE FROM 
(
select IF(result="right",1,0) as ar,device_id,difficult_level FROM question_practice_detail  LEFT JOIN question_detail 
on question_practice_detail.question_id=question_detail.question_id
)  
a 
WHERE device_id IN (select device_id from  user_profile where university=' Zhejiang University ')
GROUP BY difficult_level ORDER BY RATE
原网站

版权声明
本文为[Data analysis of financial Xiaobai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130802179320.html