当前位置:网站首页>Limited query of common SQL operations
Limited query of common SQL operations
2022-07-05 01:46:00 【stitchshaw】
topic 1
https://www.nowcoder.com/practice/fbe36305c6dd4954a05cc2f2f12e4f4a?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0
select uid, nick_name, register_time
from user_info
order by register_time asc
limit 3
select uid, nick_name, register_time
from (
select uid, nick_name,register_time,
ROW_NUMBER() over(order by register_time) as ranks # Column name to rename . Column name cannot be row_number, Otherwise, the report will be wrong
from user_info
) as t
where ranks <= 3;
#limit 3;
with t as(
select uid, nick_name,register_time,
ROW_NUMBER() over(order by register_time) as ranks # Column name to rename . Column name cannot be row_number, Otherwise, the report will be wrong
from user_info
)
select uid, nick_name, register_time
from t
where ranks <= 3;
# limit 3;
topic 2
https://www.nowcoder.com/practice/718d36d2667b48faa2168b6c1521816a?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0
Mr. Cheng temporary table t, Indicates that the conditions are met ( Job search algorithm 、 Answer sheet is algorithm 、 Complete the answer sheet on the day of registration ) People's information .
The final classification , Find out the maximum score of each person and then sort .
with t as(
select t1.uid, level, register_time, score
from user_info t1 join examination_info t2 join exam_record t3 on t1.uid = t3.uid and t2.exam_id = t3.exam_id
where job=" Algorithm " and tag = ' Algorithm ' and date(register_time) = date(submit_time)
)
select uid, level, register_time, max(score) as max_score
from t
group by uid
order by max_score DESC
limit 6, 3
limit usage :【select * from tableName limit i,n 】;
i : Is the index value of the query result ( The default from the 0 Start );n : Number returned for query results
Or write directly :
select t1.uid, level, register_time, max(score) as max_score
# from user_info t1 join examination_info t2 join exam_record t3 on t1.uid = t3.uid and t3.exam_id = t2.exam_id
from user_info t1 join exam_record using(uid) join examination_info using(exam_id)
where
job = " Algorithm " # job like ' Algorithm '
and tag = ' Algorithm ' # tag like ' Algorithm '
and date(register_time) = date(submit_time) # use date function , That is, take the date
# and DATE_FORMAT(register_time, '%Y%m%d')=DATE_FORMAT(submit_time, '%Y%m%d')
group by uid
order by max_score desc
limit 6, 3 # Take the first place 7~9 strip
边栏推荐
- Introduction to redis (1)
- 【CTF】AWDP总结(Web)
- 19. Delete the penultimate node of the linked list
- One click generation and conversion of markdown directory to word format
- 如何搭建一支搞垮公司的技術團隊?
- 线上故障突突突?如何紧急诊断、排查与恢复
- node工程中package.json文件作用是什么?里面的^尖括号和~波浪号是什么意思?
- PHP 基础篇 - PHP 中 DES 加解密详解
- Interesting practice of robot programming 16 synchronous positioning and map building (SLAM)
- Nebula Importer 数据导入实践
猜你喜欢

Interesting practice of robot programming 14 robot 3D simulation (gazebo+turtlebot3)

微信小程序:微群人脉微信小程序源码下载全新社群系统优化版支持代理会员系统功能超高收益

Wechat applet: the latest WordPress black gold wallpaper wechat applet two open repair version source code download support traffic main revenue

Roads and routes -- dfs+topsort+dijkstra+ mapping

Phpstrom setting function annotation description

STM32 series - serial port UART software pin internal pull-up or external resistance pull-up - cause problem search

Wechat applet: Xingxiu UI v1.5 WordPress system information resources blog download applet wechat QQ dual end source code support WordPress secondary classification loading animation optimization

How to build a technical team that will bring down the company?

Express routing, express middleware, using express write interface

phpstrom设置函数注释说明
随机推荐
One plus six brushes into Kali nethunter
Talk about the things that must be paid attention to when interviewing programmers
Wechat applet; Gibberish generator
85.4% mIOU! NVIDIA: using multi-scale attention for semantic segmentation, the code is open source!
runc hang 导致 Kubernetes 节点 NotReady
Wechat applet: Xingxiu UI v1.5 WordPress system information resources blog download applet wechat QQ dual end source code support WordPress secondary classification loading animation optimization
Codeforces Global Round 19 ABC
PHP wechat official account development
Heartless sword English translation of Xi Murong's youth without complaint
PowerShell: use PowerShell behind the proxy server
Exploration and Practice of Stream Batch Integration in JD
One click generation and conversion of markdown directory to word format
Can financial products be redeemed in advance?
Restful fast request 2022.2.1 release, support curl import
Classification of performance tests (learning summary)
Redis master-slave replication cluster and recovery ideas for abnormal data loss # yyds dry goods inventory #
Binary tree traversal - middle order traversal (golang)
"2022" is a must know web security interview question for job hopping
JVM's responsibility - load and run bytecode
Interpretation of mask RCNN paper