xiu上图二插入错误 顺序。 条件没看清
sql重新写
在这里插入代码片
sqlselect up.university,count(qpd.question_id)/count(distinct qpd.device_id) avg_answer_cnt
from user_profile up inner join question_practice_detail qpd
on up.device_id=qpd.device_id
group by university
yan花了 晕
不是说where后不能跟聚合函数? 查一下 where后是否能跟聚合函数
添加链接描述
group by是聚合函数吗 能和where放一块吗
添加链接描述
select
up.university,qd.difficult_level,count(qpd.question_id)/count(distinct qpd.device_id)
from user_profile up,question_practice_detail qpd,question_detail qd
where up.device_id=qpd.device_id and qpd.question_id=qd.question_id
and university='山东大学'
group by difficult_level
牛客网取消答题成功声音
在这里插入代码片
select
if(age>=25,'25岁及以上','25岁以下')as age_cut,
count(device_id) as number
from user_profile
group by age_cut
select
device_id,gender,age,gpa
from user_profile
where university='山东大学'
union all
select device_id,gender,age,gpa
from user_profile
where gender='male'
在这里插入代码片
select
device_id,gender,
case
when age>=25 then '25岁及以上'
when age between 20 and 24 then'20-24岁'
when age<24 then '20岁以下'
else '其他'
end
As age_cut
from user_profile
,逗号问题
无语
单引号 引用