当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
numpy和tensor增加或删除一个维度
Eight-legged text of mysql
每日sql -用户两天留存率
八股文之并发编程
Attitude solution - gyroscope + Euler method
导航定位中的坐标系
Eight-legged text jvm
知识蒸馏Knownledge Distillation
iptables nat
MySQL01
HCIP实验(pap、chap、HDLC、MGRE、RIP)
[损失函数]——均方差
window10吐槽
华为防火墙-4-安全策略
Top20 bracket matching
亚马逊获得AMAZON商品详情 API 返回值说明
每日sql - 判断+聚合
HCIA knowledge review
Daily sql-seek the sum of successful investments in 2016
1688商品详情接口