当前位置:网站首页>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
边栏推荐
猜你喜欢
MySQL之CRUD
Conference OA Project My Conference
Xshell如何连接虚拟机
HCIP MPLS/BGP Comprehensive Experiment
pytorch调整模型学习率
拼多多api接口应用示例
《Show and Tell: A Neural Image Caption Generator》论文解读
矩阵分析——Jordan标准形
淘宝商品详情API接口
HCIP-Spanning Tree (802.1D, Standard Spanning Tree/802.1W: RSTP Rapid Spanning Tree/802.1S: MST Multiple Spanning Tree)
随机推荐
HCIP OSPF动态路由协议
一种用于EEG超扫描研究的分析流程
OA项目之项目简介&会议发布
华为防火墙-5-NAT
智能合约 ——— app评分合约
《Generative Adversarial Networks》
每日sql -查询至少有5名下属的经理和选举
HCIP OSPF/MGRE Comprehensive Experiment
HCIP WPN experiment
Pinduoduo api interface application example
Spatial Pyramid Pooling -Spatial Pyramid Pooling (including source code)
拼多多API接口大全
损失函数——负对数似然
My approval of OA project (inquiry & meeting signature)
window10吐槽
Xshell如何连接虚拟机
亚马逊获得AMAZON商品详情 API 返回值说明
Top20 bracket matching
核方法 Kernel method
淘宝sku API 接口(PHP示例)