当前位置:网站首页>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
边栏推荐
- Unified blog writing environment
- Database postragesql lock management
- 如何搭建一支搞垮公司的技術團隊?
- 流批一體在京東的探索與實踐
- WCF: expose unset read-only DataMember property- WCF: Exposing readonly DataMember properties without set?
- 增量备份 ?db full
- MySQL regexp: Regular Expression Query
- Practice of tdengine in TCL air conditioning energy management platform
- Li Kou Jianzhi offer -- binary tree chapter
- Wechat applet; Gibberish generator
猜你喜欢

Redis(1)之Redis简介

A simple SSO unified login design

Win:使用 PowerShell 检查无线信号的强弱

Wechat applet: independent background with distribution function, Yuelao office blind box for making friends
![[swagger]-swagger learning](/img/60/1dbe074b3c66687867192b0817b553.jpg)
[swagger]-swagger learning

Armv8-a programming guide MMU (3)

Yyds dry goods inventory kubernetes management business configuration methods? (08)

Wechat applet: exclusive applet version of the whole network, independent wechat community contacts

"2022" is a must know web security interview question for job hopping

MATLB|多微电网及分布式能源交易
随机推荐
Application and Optimization Practice of redis in vivo push platform
微信小程序:最新wordpress黑金壁纸微信小程序 二开修复版源码下载支持流量主收益
Expansion operator: the family is so separated
Valentine's Day flirting with girls to force a small way, one can learn
What sparks can applet container technology collide with IOT
One click generation and conversion of markdown directory to word format
172. Zero after factorial
When the industrial Internet era is truly developed and improved, it will witness the birth of giants in every scene
Yyds dry goods inventory [Gan Di's one week summary: the most complete and detailed in the whole network]; detailed explanation of MySQL index data structure and index optimization; remember collectio
流批一體在京東的探索與實踐
Application and development trend of image recognition technology
Vulnstack3
[flutter topic] 64 illustration basic textfield text input box (I) # yyds dry goods inventory #
微信小程序:星宿UI V1.5 wordpress系统资讯资源博客下载小程序微信QQ双端源码支持wordpress二级分类 加载动画优化
R语言用logistic逻辑回归和AFRIMA、ARIMA时间序列模型预测世界人口
DOM basic syntax
Win:使用 PowerShell 检查无线信号的强弱
Exploration and Practice of Stream Batch Integration in JD
Interesting practice of robot programming 16 synchronous positioning and map building (SLAM)
Flutter 2.10 update details