当前位置:网站首页>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
边栏推荐
猜你喜欢
HCIP BGP建邻、联邦、汇总实验
每日sql -查询至少有5名下属的经理和选举
HCIP BGP neighbor building, federation, and aggregation experiments
Pinduoduo api interface application example
Arcgis小工具_实现重叠分析
Amazon Get AMAZON Product Details API Return Value Description
Spatial Pyramid Pooling -Spatial Pyramid Pooling (including source code)
MySQL之CRUD
arcgis填坑_1
Daily sql-seek the sum of successful investments in 2016
随机推荐
OA项目之项目简介&会议发布
八股文之mysql
deepin v20.6+cuda+cudnn+anaconda(miniconda)
MySQL之CRUD
获取拼多多商品信息操作详情
华为防火墙-7-dhcp
HCIP OSPF/MGRE综合实验
空间金字塔池化 -Spatial Pyramid Pooling(含源码)
姿态解算-陀螺仪+欧拉法
HCIP OSPF/MGRE Comprehensive Experiment
Especially the redis
OA项目之我的会议(会议排座&送审)
淘宝商品详情API接口
强烈推荐一款好用的API接口
HCIP OSPF动态路由协议
导航定位中的坐标系
LabelEncoder和LabelBinarizer的区别
HCIP BGP neighbor building, federation, and aggregation experiments
unable to extend table xxx by 1024 in tablespace xxxx
Douyin API interface