当前位置:网站首页>Daily SQL - find each of the students school gpa minimum (window)
Daily SQL - find each of the students school gpa minimum (window)
2022-08-11 07:14:00 【Eating too much sugar will not gain weight】
Title: Now the operation wants to find the students with the lowest gpa in each school for research, please take out the lowest gpa of each school.
drop table if exists user_profile;CREATE TABLE `user_profile` (`id` int NOT NULL,`device_id` int NOT NULL,`gender` varchar(14) NOT NULL,`age` int ,`university` varchar(32) NOT NULL,`gpa` float,`active_days_within_30` int ,`question_cnt` int ,`answer_cnt` int);INSERT INTO user_profile VALUES(1,2138,'male',21,'Peking University',3.4,7,2,12);INSERT INTO user_profile VALUES(2,3214,'male',null,'Fudan University',4.0,15,5,25);INSERT INTO user_profile VALUES(3,6543,'female',20,'Peking University',3.2,12,3,30);INSERT INTO user_profile VALUES(4,2315,'female',23,'Zhejiang University',3.6,5,1,2);INSERT INTO user_profile VALUES(5,5432,'male',25,'Shandong University',3.8,20,15,70);INSERT INTO user_profile VALUES(6,2131,'male',28,'Shandong University',3.3,15,7,13);INSERT INTO user_profile VALUES(7,4321,'male',28,'Fudan University',3.6,9,6,52);Projects
select b.device_id ,a.university,a.gpafrom(select university,min(gpa) as gpafrom user_profilegroup by university)a left join user_profile b on b.university = a.university and b.gpa = a.gpaorder by a.universityselect device_id,university,gpafrom (select*,row_number() over(partition by university order by gpa) as rnfrom user_profile)awhere a.rn = 1边栏推荐
猜你喜欢
随机推荐
iptables 基础配置
arcgis填坑_4
概念名词解释
会议OA项目之我的会议
iptables 流量统计
空间点模式方法_一阶效应和二阶效应
pytorch调整模型学习率
Spatial Pyramid Pooling -Spatial Pyramid Pooling (including source code)
【LeetCode】851.喧闹与富有(思路+题解)
window10吐槽
Open Set Domain Adaptation 开集领域适应
HCIP MGRE\OSPF综合实验
拼多多API接口(附上我的可用API)
《Show and Tell: A Neural Image Caption Generator》论文解读
bash的命令退出状态码
每日sql -用户两天留存率
TOP2 Add two numbers
从mask-rcnn到shp
什么是Inductive learning和Transductive learning
每日sql-员工奖金过滤和回答率排序第一





![[损失函数]——均方差](/img/55/e3c1797d5e87ddfb72bf39c5d31168.png)



