Sql综合练习

目录

21年8月份练题总数

现在运营想要了解2021年8月份所有练习过题目的总用户数和练习过题目的总次数,请取出相应结果。

sql 复制代码
select
    count(distinct device_id) as did_cnt,
    count(question_id) as question_cnt
from
    question_practice_detail
where
    date like "2021-08%"

统计复旦用户8月练题情况

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

sql 复制代码
select
    up.device_id,
    '复旦大学' as university,
    count(question_id) as question_cnt,
    sum(if (qpd.result = 'right', 1, 0)) as right_question_cnt
from
    user_profile as up
    left join question_practice_detail as qpd on qpd.device_id = up.device_id
    and month (qpd.date) = 8
where
    up.university = '复旦大学'
group by
    up.device_id

浙大不同难度题目的正确率

现在运营想要了解浙江大学的用户在不同难度题目下答题的正确率情况,请取出相应数据,并按照准确率升序输出。

sql 复制代码
select
    t3.difficult_level,
    avg(
        case
            when t1.result = 'right' then 1
            else 0
        end
    ) as correct_rate
from
    question_practice_detail t1
    left join user_profile t2 on t1.device_id = t2.device_id
    left join question_detail t3 on t1.question_id = t3.question_id
where
    t2.university = '浙江大学'
group by
    t3.difficult_level
order by
    correct_rate
相关推荐
星幻元宇VR7 小时前
VR环保学习机|科技助力绿色教育新模式
大数据·科技·学习·安全·vr·虚拟现实
_一只小QQ7 小时前
软考中级第二节
学习
Sunshine for you7 小时前
如何用FastAPI构建高性能的现代API
jvm·数据库·python
阿贵---8 小时前
Python Web爬虫入门:使用Requests和BeautifulSoup
jvm·数据库·python
小飞菜涅8 小时前
fast-lio2复现
嵌入式硬件·学习·ubuntu
道清茗8 小时前
【MySQL知识点问答题】 MySQL 配置参数和内存管理
数据库·mysql
城数派8 小时前
全国乡镇(街道)点位数据2025年(shp格式\excel格式)
arcgis·信息可视化·数据分析
2401_884563248 小时前
进阶技巧与底层原理
jvm·数据库·python
2401_873204658 小时前
使用Pandas进行数据分析:从数据清洗到可视化
jvm·数据库·python
ZGi.ai8 小时前
生产级 Agent 编排 从单一 LLM 调用到多智能体工作流的工程设计
大数据·数据库·人工智能