当前位置:网站首页>Li Kou achieved the second largest result
Li Kou achieved the second largest result
2022-07-27 05:09:00 【Meme_ xp】

To get the second highest , Need to sort , Use order by( The default is ascending asc, From small to large ), If you want to reduce the order, use the keyword desc
duplicate removal , If there are multiple identical data , Use keywords distinct duplicate removal
Judge the critical output , If there is no second highest salary , The query should return null, Use ifNull( Inquire about ,null) Method
names , Use keywords as …
Because it's heavy , And then sort in order , Use limit Method , Query the second largest data , The second highest salary , namely limit 1,1( Because the default is from 0 Start , So the first one 1 Is the second largest number of queries , the second 1 It means how many pieces of data will be displayed in the future , Only one is needed here )
select ifNull((
select distinct Salary
from Employee
order by Salary desc limit 1,1),null) as SecondHighestSalary
Key points ifnull and limit
IFNULL and COALESCE difference ?
IFNULL and COALESCE It is to deal with the case that the first value is empty .
ifnull: If it's empty, we'll fill it in

I want to see others coalesce

coalesce(a,b,c), If a Empty value , use b fill , If b Empty value , use c fill !!!!!!!!
The difference lies in IFNULL Only two parameters are allowed ,COALESCE It can have two or more parameters
NULLIF What is it? ?
NULLIF(expression1 ,expression2) If expression1=expression2 Then return to null, otherwise expression1
limit
usage
1.limit a( The first four articles )
2.limit a,b( Subscript 0 At the beginning )
3.limit 4 offset 10 ( Query the first 11,12,13,14 Four )
4. To retrieve all record lines from an offset to the end of the recordset , The second parameter can be specified as -1—————————— LIMIT 95 , - 1 // Retrieve record lines 96 - last.
limit() Methods cannot be involved in operations
therefore limit(N+1,1) It's wrong.
边栏推荐
- C语言 通讯录管理系统(链表,手机号码分段存储,txt文件存取,完整源码)
- Constraints of MySQL table
- 2、 MySQL advanced
- MySQL下载安装 & 完美卸载
- Sub database and sub table
- "Photoshop2021 tutorial" adjust the picture to different aspect ratio
- Use of file i/o in C
- Demo of throttling function -- regular expression matching
- Be diligent in talking about what sidelines you can do now
- Deep Qt5 signal slot new syntax
猜你喜欢

How to sinicize the JMeter interface?

File dialog box

【搜索】Flood Fill 和 最短路模型

Installation and template setting of integrated development environment pychar

Use ngrok for intranet penetration

Acticiti中startProcessInstanceByKey方法在variable表中的如何存储

How to import PS style? Photoshop style import tutorial

动态内存函数的介绍(malloc free calloc realloc)

The project connects with Alipay payment, and the intranet penetration realizes the monitoring of asynchronous callback notification of successful payment of Alipay

Review of various historical versions of Photoshop and system requirements
随机推荐
Idea 如何新建一个groovy的项目(图文详细解释)
二叉搜索树详讲
C语言 通讯录管理系统(链表,手机号码分段存储,txt文件存取,完整源码)
Jmeter 界面如何汉化?
树莓派rtmp推流本地摄像头图像
Event Summary - common summary
《Robust and Precise Vehicle Localization based on Multi-sensor Fusionin Diverse City Scenes》翻译
1、 MySQL Foundation
How to copy Photoshop layers to other documents
SVN使用详解
事件的接受与忽略
Sub database and sub table
Laozi cloud and Fuxin Kunpeng achieved a major breakthrough in 3D ofd 3D format documents for the first time
Invert a Binary Tree
MQ message queue is used to design the high concurrency of the order placing process, the generation scenarios and solutions of message squeeze, message loss and message repetition
What is the future development direction of software testing engineers?
Raspberry pie output PWM wave to drive the steering gear
项目对接支付宝支付,内网穿透实现监听支付宝的支付成功异步回调通知
QT menu bar, toolbar and status bar
事件过滤器