当前位置:网站首页>Record of SQL questions of Niuke this week
Record of SQL questions of Niuke this week
2022-07-18 23:33:00 【Statichit static smash】

This topic is mainly about substring_index The use of functions , Pay attention to and substring distinguish .

Complete code :
select substring_index(profile,',',-1) gender, count(*) number
from user_submit
group by gender

The problem is very simple . Observe the law , Use what you learned in the previous question substring Function is OK .
Complete code :
select device_id,substring(blog_url,11) as user_name
from user_submit
Needless to say .
select substring_index(substring_index(profile,',',3),',',-1) as age ,count(*) number
from user_submit
group by age
order by age desc
Complete code :
select device_id,university,gpa
from user_profile
where (university,gpa) in(
select university,min(gpa) from user_profile group by university
)
order by universitySeveral points for attention in this problem
1. be used group by keyword , The fields behind it must appear in select Back .
2. be used in keyword , If there are multiple fields , The front and back should be enclosed in parentheses .

Complete code :
select t1.device_id,t1.university,
count(t2.question_id) question_cnt,
sum(case
when t2.result ='right' then 1
else 0
end
)right_question_cnt
from user_profile t1
left join question_practice_detail t2
on(t1.device_id = t2.device_id and month(t2.date)=8)
where(t1.university = ' Fudan University ' )
group by t1.device_id;
Encounter such a big comprehensive problem , Carefully analyze the disassembly requirements .
Correct number of questions , Should be right and wrong assignment , And add the results to get the correct result ( Use of the sum and case function )
When querying linked tables , Take the time and month requirements into the filter ( It's used here month Time function and linked table query left join ...on...)
By observing the output sample, we can know that it is based on the user id Grouped .
边栏推荐
- 7、常见的垃圾回收器
- Supervised learning week 3: logistic regression option_ Lab harvest record
- Mysql事务隔离机制
- gdb 调试技巧:定位程序卡死问题
- 常见密码正则表达式
- [white box test] design method of logic coverage and path test
- Mysql内部架构
- 过拟合 欠拟合
- What will the future responsive web design look like under the endless demand of terminal device adaptation?
- 11(2).结构体的存储方式,结构体变量和结构体变量指针作为函数参数传递的问题,指针的优点
猜你喜欢

T-infinite Road

Design of DHT11 temperature and humidity sensor based on stm32

ZVS电路初步测试

Supervised learning week 3: logistic regression option_ Lab harvest record

微信小程序_16,组件的生命周期

6、JVM分代模型--老年代 的垃圾回收
![[C language] explanation and Simulation Implementation of strlen function](/img/70/8d94366ae19a8ab07979d808663c89.png)
[C language] explanation and Simulation Implementation of strlen function

Do you want to switch to software testing? A comprehensive analysis

Developers must see | devweekly issue 1: what is time complexity?

从零复现PyTorch版(2)
随机推荐
leetcode-两数之和
ImportError: cannot import name ‘Imputer‘ from ‘sklearn. preprocessing‘
Web crawler technology from entry to mastery (penetration of high-end operations) Chapter 2
星巴克不使用两阶段提交
pytest接口自动化测试框架 | pytest简介
Dameng database table SQL statement
Leetcode sum of two numbers
(pytorch advanced road III) conv2d
[decision tree] use decision tree to diagnose breast cancer
11、摸清JVM对象分布
(pytorch advanced road IV) vision transformer
T-infinite Road
pytest接口自动化测试框架 | 接口关联
Buffer Pool 核心原理
Lifeguard certificate examination
Interviewer: tell me about the most valuable bug you found in your work
ospf综合实验
STM32F1与STM32CubeIDE编程实例-W25Q-SPI-Flash驱动
OSPF comprehensive experiment
Learning record: FSMC - extended external SRAM