You are viewing a single comment's thread from:

RE: 软件工程师数据库面试技巧之 SQL中的第二名记录 Software Engineer Interview Question - The Second Highest

in #cn7 years ago

要是找个工资第100高的。岂不是要累屎。。。。

Sort:  

找第100高的, 估计只能用你上面的这个方法了。

但是当第二高记录不存在时, 该SQL返回空而不是 null.
刚试了一下,用 group + order
select Salary as SecondHighestSalary from Employee group by Salary order by Salary limit 1,1
Input: {"headers": {"Employee": ["Id", "Salary"]}, "rows": {"Employee": [[1, 100]]}}
Output: {"headers": ["SecondHighestSalary"], "values": []}
Expected: {"headers": ["SecondHighestSalary"], "values": [[null]]}

嗯就是没有记录吧

你过的是英国的时间么?天天晚睡,记得保养啊

我是真的睡不着。。。。我也没办法。。。

你男人呢?

他也是睡眠不规律。不过他比我入睡更容易一些。

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.030
BTC 58679.35
ETH 3155.04
USDT 1.00
SBD 2.44