文章目录
- 1. 题目
- 2. 解题
1. 题目
编写一个 SQL 语句,获取球员 (players) 表中第二高的身高 (height)
表定义: players (球员表)
https://www.lintcode.com/problem/1918
2. 解题
if(a,b,c)
, a true,执行 b, 否则 c
-- Write your SQL Query here --
-- example: SELECT * FROM XX_TABLE WHERE XXX --
select
(
if(
(select count(*) from (select distinct height from players) p) >= 2,
(select distinct height from players order by height desc limit 1 offset 1),
NULL
)
) second_height