当前位置:网站首页>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.
边栏推荐
- When using Photoshop, the prompt "script error -50 general Photoshop error appears“
- Network protocol details: IP
- STM32_ HAL_ SUMMARY_ NOTE
- 2022 T2i text generated image Chinese Journal Paper quick view-1 (ecagan: text generated image method based on channel attention mechanism +cae-gan: text generated image technology based on transforme
- Transaction database and its four characteristics, principle, isolation level, dirty read, unreal read, non repeatable read?
- Hiding skills of Photoshop clipping tool
- Replication of df-gan experiment -- detailed steps of replication of dfgan and forwarding from remote port to local port using mobaxtem
- Test basis 5
- 智慧展厅设计的优势及适用行业分析
- 深入 Qt5 信号槽新语法
猜你喜欢
![[search] flood fill and shortest path model](/img/22/5240c9ff6ea3c7c1017e3e9a4a27cb.png)
[search] flood fill and shortest path model

What about PS too laggy? A few steps to help you solve the problem

Unit test Chapter6

Another skill is to earn 30000 yuan a month+

Transaction database and its four characteristics, principle, isolation level, dirty read, unreal read, non repeatable read?

来自“飞人”乔丹的启示!奥尼尔开启的另一个“赛场”

会议OA之我的审批

《Robust and Precise Vehicle Localization based on Multi-sensor Fusionin Diverse City Scenes》翻译

Reproduce ssa-gan using the nine day deep learning platform

What if Photoshop prompts that the temporary storage disk is full? How to solve the problem that PS temporary storage disk is full?
随机推荐
精选用户故事|洞态在聚水潭的误报率几乎为0,如何做到?
Knapsack problem DP
Explanation of index failure principle and its common situations
Invert a Binary Tree
Jmeter 界面如何汉化?
How to copy Photoshop layers to other documents
报错:cannot read poperties of undefined(reading ‘then‘)
Transaction database and its four characteristics, principle, isolation level, dirty read, unreal read, non repeatable read?
The execution process of a select statement in MySQL
节流函数的demo——正则表达式匹配
Raspberry pie output PWM wave to drive the steering gear
ssm框架整合
再一个技巧,每月稳赚3万+
Install pyGame
1、 MySQL Foundation
Unit test Chapter6
文件处理(IO)
[error reporting]: cannot read properties of undefined (reading 'prototype')
Introduction to MySQL optimization
How does PS import LUT presets? Photoshop import LUT color preset tutorial