问题1:查询出Person表中重复的email
Person表
id email
1 zhoujie@yikongenomics.com
2 sunmengfei@yikongenomics.com
3 lisuxiang@yikongenomics.com
4 zhoujie@yikongenomics.com
select email from Person group by email having count(email)>1;
问题2:交换男(m)女(f)
salary表
id name salary sex
1 A 1000 m
2 B 2000 f
3 C 3000 m
4 D 4000 f
update salary set sex=
case sex when 'm' then 'f'
when 'f' then 'm'
end;
问题3:返回第二高的薪水
id salary
1 100
2 200
3 300
4 400
select salary from tb_salary order by salary desc limit 1 offset 1;