xzrnb

导航

 

现在运营想要了解复旦大学的每个用户在8月份练习的总题目数和回答正确的题目数情况,请取出相应明细数据,对于在8月份没有练习过的用户,答题数结果返回0.

select u.device_id,university,count(question_id) as question_cnt,
        count(case when result = 'right' then 1 else null end) as right_question_cnt
from user_profile u
left join question_practice_detail q
on u.device_id = q.device_id
where university = '复旦大学'
and (month(date) = 8 or date is null)
group by u.device_id

1.回答正确的题目数情况

count(case when result = 'right' then 1 else null end) as right_question_cnt
case 
  when reuslt = 'right'
  then 1
  else null
end

2.也要统计8月份没有联系过的用户

and (month(date) = 8 or date is null)

java
1.输入字符串的语法

String str = sc.nextLine();

2.输入字符的语法

char a = in.next().charAt(0);

对于字符输入(char)需要使用 .charAt(0) 方法来获取字符串中的字符

posted on 2024-03-26 10:06  翻斗花园第一狙击手  阅读(10)  评论(0编辑  收藏  举报