当前位置:网站首页>Guest brush SQL - 2
Guest brush SQL - 2
2022-08-01 06:02:00 【Mmm okay!】
作者简介:大家好我是小唐同学(><),大家可以叫我小唐
个人主页:小唐同学(?>?<?)的博客主页
系列专栏:牛客网刷SQL
大家如果有求职需要或者刷题需要可以点开链接直接注册,一起刷题:点击跳转
牛客网支持ACM模式哦,刷算法题也很推荐哦!!!
SQL37查找后多列排序
描述
题目:现在运营想要取出用户信息表中的年龄和gpa数据,并先按照gpa升序排序,再按照年龄升序排序输出,请取出相应数据.
用户信息表:user_profile
id
device_id
gender
age
university
gpa
1
2138
male
21
北京大学
3.4
2
3214
male
23
复旦大学
4
3
6543
female
20
北京大学
3.2
4
2315
female
23
浙江大学
3.6
5
5432
male
25
山东大学
3.8
6
2131
male
28
北京师范大学
3.3
你的查询应返回以下结果:
device_id
gpa
age
6534
3.2
20
2131
3.3
28
2138
3.4
21
2315
3.6
23
5432
3.8
25
3214
4
23
示例1
输入:
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);
INSERT INTO user_profile VALUES(1,2138,‘male’,21,‘北京大学’,3.4);
INSERT INTO user_profile VALUES(2,3214,‘male’,23,‘复旦大学’,4.0);
INSERT INTO user_profile VALUES(3,6543,‘female’,20,‘北京大学’,3.2);
INSERT INTO user_profile VALUES(4,2315,‘female’,23,‘浙江大学’,3.6);
INSERT INTO user_profile VALUES(5,5432,‘male’,25,‘山东大学’,3.8);
INSERT INTO user_profile VALUES(6,2131,‘male’,28,‘北京师范大学’,3.3);
复制输出:
6543|3.200|20
2131|3.300|28
2138|3.400|21
2315|3.600|23
5432|3.800|25
3214|4.000|23
select device_id,gpa,age from user_profile order by gpa ,age;
SQL38查找后降序排列
描述
题目:现在运营想要取出用户信息表中对应的数据,并先按照gpa、年龄降序排序输出,请取出相应数据.
示例user_profile:
id
device_id
gender
age
university
gpa
1
2138
male
21
北京大学
3.4
2
3214
male
23
复旦大学
4
3
6543
female
20
北京大学
3.2
4
2315
female
23
浙江大学
3.6
5
5432
male
25
山东大学
3.8
6
2131
male
28
北京师范大学
3.3
根据示例,你的查询应返回以下结果:
device_id
gpa
age
3214
4
23
5432
3.8
25
2315
3.6
23
2138
3.4
21
2131
3.3
28
6543
3.2
20
示例1
输入:
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);
INSERT INTO user_profile VALUES(1,2138,‘male’,21,‘北京大学’,3.4);
INSERT INTO user_profile VALUES(2,3214,‘male’,23,‘复旦大学’,4.0);
INSERT INTO user_profile VALUES(3,6543,‘female’,20,‘北京大学’,3.2);
INSERT INTO user_profile VALUES(4,2315,‘female’,23,‘浙江大学’,3.6);
INSERT INTO user_profile VALUES(5,5432,‘male’,25,‘山东大学’,3.8);
INSERT INTO user_profile VALUES(6,2131,‘male’,28,‘北京师范大学’,3.3);
复制输出:
3214|4.0|23
5432|3.8|25
2315|3.6|23
2138|3.4|21
2131|3.3|28
6543|3.2|20
select device_id, gpa, age from user_profile order by gpa desc,age desc ;
再向大家说一遍 牛客网真的是很好的刷题 提升自己的平台 而且它还是一个找工作的平台 有专门的各个公司的入职面经
真的很向大家推荐
真的很建议大家来到牛客一起刷题学习!!!!!
大家如果有意愿可以点开链接注册一起刷题哦点我跳转
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在.深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小.自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前.因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担.添加下方名片,即可获取全套学习资料哦
边栏推荐
- 说说js中使用for in遍历数组存在的bug
- 仿牛客网项目总结
- Jupyter shortcuts
- 2022.7.27 Selected lectures on good topics
- Selenium: mouse, keyboard events
- 测试工具(四)Jenkins环境搭建与使用
- Matlab simulink particle swarm optimization fuzzy pid control motor pump
- Vsce package after the Command failed: NPM list - production - parseable - the depth = 99999 - loglevel = error exception
- 对于升级go1.18的goland问题
- The BP neural network based on MATLAB voice characteristic signal classification
猜你喜欢
从底层结构开始学习FPGA(6)----分布式RAM(DRAM,Distributed RAM)
Qt Widget 项目对qml的加载实例
声音信号处理基频检测和时频分析
curl (7) Failed connect to localhost8080; Connection refused
滚动条样式修改
Sound Signal Processing Fundamental Frequency Detection and Time-Frequency Analysis
MySQL-Data Operation-Group Query-Join Query-Subquery-Pagination Query-Joint Query
「游戏引擎 浅入浅出」4.1 Unity Shader和OpenGL Shader
【FiddlerScript】利用FiddlerScript抓包保利威下载
WebSocket implements chat function
随机推荐
基于MATLAB的BP神经网络进行语音特征信号分类
Selenium: browser operation
AspNet.WebApi.Owin custom Token request parameters
2022/07/29 入职健海JustFE团队,我学到了高效开发(年中总结)
安装SQL Server详细教程
Selenium: Introduction
【翻译】确保云原生通信的安全:从入口到服务网及更远的地方
Qt Widget 项目对qml的加载实例
图片更新之后Glide加载依旧是原来的图片问题
LeetCode Question of the Day (309. Best Time to Buy and Sell Stock with Cooldown)
[Translation] Securing cloud-native communications: From ingress to service mesh and beyond
2022.7.27好题选讲
小白的0基础教程SQL: 关系数据库概述 02
微信小程序用户登录auth.code2Session接口开发
Selenium: JS operation
Does flinkcdc have any solution for mysql's date field type conversion?
matlab 风速模型 小波滤波
Dialogue with the father of MySQL: One excellent programmer is worth 5 ordinary programmers
torch
return;代表含义